diff --git a/app/src/main/java/nz/badradio/badradio/model/metadata/art/BandcampCrawler.kt b/app/src/main/java/nz/badradio/badradio/model/metadata/art/BandcampCrawler.kt index a86a144..3accbd8 100644 --- a/app/src/main/java/nz/badradio/badradio/model/metadata/art/BandcampCrawler.kt +++ b/app/src/main/java/nz/badradio/badradio/model/metadata/art/BandcampCrawler.kt @@ -1,6 +1,5 @@ package nz.badradio.badradio.model.metadata.art -import android.util.Log import nz.badradio.badradio.model.metadata.SongMetadata import nz.badradio.badradio.utilities.buildSearchUrl import nz.badradio.badradio.utilities.executeRequestAndCheckResponse diff --git a/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/BandcampCrawlerTests.kt b/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/BandcampCrawlerTests.kt index aeab52d..920db30 100644 --- a/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/BandcampCrawlerTests.kt +++ b/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/BandcampCrawlerTests.kt @@ -33,13 +33,14 @@ class BandcampCrawlerTests { @Test fun testGetImageUrl() { - val mockSearchResponseContent = File("${responsesFilesDirectory}/bandcamp_search_response.html") - .readText(Charsets.UTF_8) + var mockSearchResponseContent = File( + "${responsesFilesDirectory}/bandcamp_search_response.html", + ).readText(Charsets.UTF_8) + mockSearchResponseContent = mockSearchResponseContent + .replace("https://cassyb.bandcamp.com", baseUrl.toString()) val mockSearchResponse = MockResponse().setBody(mockSearchResponseContent) mockWebServer.enqueue(mockSearchResponse) - // TODO: second call not working??? - // base url different: cassyb.bandcamp.com val mockSongPageResponseContent = File("${responsesFilesDirectory}/bandcamp_song_page.html") .readText(Charsets.UTF_8) val mockSongPageResponse = MockResponse().setBody(mockSongPageResponseContent) @@ -62,6 +63,12 @@ class BandcampCrawlerTests { @Test fun testGetSongUrl() { + val mockSearchResponseContent = File( + "${responsesFilesDirectory}/bandcamp_search_response.html", + ).readText(Charsets.UTF_8) + val mockSearchResponse = MockResponse().setBody(mockSearchResponseContent) + mockWebServer.enqueue(mockSearchResponse) + val songUrl = BandcampCrawler(baseUrl.toString()).getSongUrl( object : IStreamingServiceDataObserver { override fun notifyOfAlbumArtUrl(url: String) { } diff --git a/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/test_bandcamp_responses.sh b/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/test_bandcamp_responses.sh new file mode 100755 index 0000000..17088dd --- /dev/null +++ b/app/src/test/java/nz/badradio/badradio/model/metadata/art/bandcamp/test_bandcamp_responses.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +function download_file() { + url="$1" + file_name="$2" + temp_file=/tmp/$file_name + + wget "$url" > $temp_file + + diff $temp_file $test_data_file +} + +download_file "https://bandcamp.com/search?q=come%20and%20see%20cassyb&item_type=t" bandcamp_search_response.html +download_file "https://cassyb.bandcamp.com/track/come-and-see-w-north-posse" bandcamp_song_page.html +