Add updatePlaylist() call.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-09-03 10:25:36 +02:00
parent 02902023da
commit 8bf9399e48
2 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,85 @@
package org.moire.ultrasonic.api.subsonic
import org.junit.Test
/**
* Integration test for [SubsonicAPIClient] for updatePlaylist call.
*/
class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.updatePlaylist(10).execute()
}
}
@Test
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.updatePlaylist(15).execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass playlist id param in request`() {
val id = 5453L
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "playlistId=$id") {
client.api.updatePlaylist(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.updatePlaylist(22, name = name).execute()
}
}
@Test
fun `Should pass comment param in request`() {
val comment = "some-unusual-comment"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "comment=$comment") {
client.api.updatePlaylist(42, comment = comment).execute()
}
}
@Test
fun `Should pass public param in request`() {
val public = true
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "public=$public") {
client.api.updatePlaylist(53, public = public).execute()
}
}
@Test
fun `Should pass song ids to update in request`() {
val songIds = listOf(45L, 81L)
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songIdToAdd=${songIds[0]}&songIdToAdd=${songIds[1]}") {
client.api.updatePlaylist(25, songIdsToAdd = songIds).execute()
}
}
@Test
fun `Should pass song indexes to remove in request`() {
val songIndexesToRemove = listOf(129, 1)
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songIndexToRemove=${songIndexesToRemove[0]}&" +
"songIndexToRemove=${songIndexesToRemove[1]}") {
client.api.updatePlaylist(49, songIndexesToRemove = songIndexesToRemove).execute()
}
}
}

View File

@ -99,4 +99,13 @@ interface SubsonicAPIDefinition {
@GET("deletePlaylist.view")
fun deletePlaylist(@Query("id") id: Long): Call<SubsonicResponse>
@GET("updatePlaylist.view")
fun updatePlaylist(
@Query("playlistId") id: Long,
@Query("name") name: String? = null,
@Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<Long>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null) : Call<SubsonicResponse>
}