mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-18 04:30:48 +01:00
Add scrobble call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
7143dc4db1
commit
9892805517
@ -0,0 +1,55 @@
|
||||
package org.moire.ultrasonic.api.subsonic
|
||||
|
||||
import org.junit.Test
|
||||
import java.util.Calendar
|
||||
|
||||
/**
|
||||
* Integration test for [SubsonicAPIClient] for scrobble call.
|
||||
*/
|
||||
class SubsonicApiScrobbleTest : SubsonicAPIClientTest() {
|
||||
@Test
|
||||
fun `Should handle error response`() {
|
||||
checkErrorCallParsed(mockWebServerRule) {
|
||||
client.api.scrobble("id").execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should handle ok response`() {
|
||||
mockWebServerRule.enqueueResponse("ping_ok.json")
|
||||
|
||||
val response = client.api.scrobble("id").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass id param in request`() {
|
||||
val id = "some-id"
|
||||
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
|
||||
expectedParam = "id=$id") {
|
||||
client.api.scrobble(id = id).execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass time param in request`() {
|
||||
val time = Calendar.getInstance().timeInMillis
|
||||
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
|
||||
expectedParam = "time=$time") {
|
||||
client.api.scrobble(id = "some-id", time = time).execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass submission param in request`() {
|
||||
val submission = false
|
||||
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
|
||||
expectedParam = "submission=$submission") {
|
||||
client.api.scrobble(id = "some-id", submission = submission).execute()
|
||||
}
|
||||
}
|
||||
}
|
@ -118,4 +118,9 @@ interface SubsonicAPIDefinition {
|
||||
@GET("getLyrics.view")
|
||||
fun getLyrics(@Query("artist") artist: String? = null,
|
||||
@Query("title") title: String? = null): Call<GetLyricsResponse>
|
||||
|
||||
@GET("scrobble.view")
|
||||
fun scrobble(@Query("id") id: String,
|
||||
@Query("time") time: Long? = null,
|
||||
@Query("submission") submission: Boolean? = null): Call<SubsonicResponse>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user