Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TmdbSeasonDetail images parsing #117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ data class TmdbVideo(
@Serializable
data class TmdbImages(
@SerialName("id") val id: Int? = null,
@SerialName("posters") val posters: List<TmdbFileImage>,
@SerialName("backdrops") val backdrops: List<TmdbFileImage>
@SerialName("posters") val posters: List<TmdbFileImage> = emptyList(),
@SerialName("backdrops") val backdrops: List<TmdbFileImage> = emptyList()
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ data class TmdbSeasonDetail(
val episodes: List<TmdbEpisode>? = null,
@SerialName("external_ids") val externalIds: TmdbExternalIds? = null,
@SerialName("videos") val videos: TmdbResult<TmdbVideo>? = null,
@SerialName("images") val images: TmdbResult<TmdbImages>? = null
@SerialName("images") val images: TmdbImages? = null
) : TmdbAnyMedia, TmdbPosterMedia {

val numberOfEpisodes get() = episodeCount ?: episodes?.size ?: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package app.moviebase.tmdb.api

import app.moviebase.tmdb.core.mockHttpClient
import app.moviebase.tmdb.model.AppendResponse
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test

class TmdbSeasonApiTest {

val client = mockHttpClient(
version = 3,
responses = mapOf(
"tv/63333/season/1?append_to_response=release_dates,images,credits,tv_credits,external_ids&include_image_language=" to "tv/tv_season_63333_season_1.json",
),
)
val classToTest = TmdbShowSeasonsApi(client)

@Test
fun `it can fetch season details with images`() = runTest {
val seasonDetails = classToTest.getDetails(
63333,
1,
null,
listOf(
AppendResponse.RELEASES_DATES,
AppendResponse.IMAGES,
AppendResponse.CREDITS,
AppendResponse.TV_CREDITS,
AppendResponse.EXTERNAL_IDS,
),
"",
)

assertEquals(68878, seasonDetails.id)
assertNotNull(seasonDetails.images)

val imageFile = seasonDetails.images?.posters?.firstOrNull()
assertEquals("/oQasSKPcBLcEG5rOUg3s1Ozpr4s.jpg", imageFile?.filePath)
}
}
Loading
Loading