mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-18 04:30:48 +01:00
Add createPlaylist api call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
f55f19a3b8
commit
bb64b9e3ca
@ -0,0 +1,54 @@
|
||||
package org.moire.ultrasonic.api.subsonic
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Integration test for [SubsonicAPIClient] for createPlaylist call.
|
||||
*/
|
||||
class SubsonicApiCreatePlaylistTest : SubsonicAPIClientTest() {
|
||||
@Test
|
||||
fun `Should handle error response`() {
|
||||
checkErrorCallParsed(mockWebServerRule) {
|
||||
client.api.createPlaylist().execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should hanlde ok response`() {
|
||||
mockWebServerRule.enqueueResponse("ping_ok.json")
|
||||
|
||||
val response = client.api.createPlaylist().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass id param in request`() {
|
||||
val id = 56L
|
||||
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
|
||||
expectedParam = "playlistId=$id") {
|
||||
client.api.createPlaylist(id = id).execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass name param in request`() {
|
||||
val name = "some-name"
|
||||
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
|
||||
expectedParam = "name=$name") {
|
||||
client.api.createPlaylist(name = name).execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass song id param in request`() {
|
||||
val songId = listOf(4410L, 852L)
|
||||
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
|
||||
expectedParam = "songId=${songId[0]}&songId=${songId[1]}") {
|
||||
client.api.createPlaylist(songIds = songId).execute()
|
||||
}
|
||||
}
|
||||
}
|
@ -91,4 +91,9 @@ interface SubsonicAPIDefinition {
|
||||
|
||||
@GET("getPlaylists.view")
|
||||
fun getPlaylists(@Query("username") username: String? = null): Call<GetPlaylistsResponse>
|
||||
|
||||
@GET("createPlaylist.view")
|
||||
fun createPlaylist(@Query("playlistId") id: Long? = null,
|
||||
@Query("name") name: String? = null,
|
||||
@Query("songId") songIds: List<Long>? = null): Call<SubsonicResponse>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user