|
@@ -30,53 +30,6 @@ def test_bad_mopidy_request_data(client, valid_auth_token):
|
|
|
)
|
|
|
|
|
|
|
|
|
-@pytest.mark.parametrize(
|
|
|
- "seconds, expected_percent_played, expected_scrobble_id",
|
|
|
- [
|
|
|
- (1, 1, 1),
|
|
|
- (58, 96, 1),
|
|
|
- (59, 98, 1),
|
|
|
- (60, 100, 1),
|
|
|
- (1, 1, 1),
|
|
|
- (1, 1, 1),
|
|
|
- ],
|
|
|
-)
|
|
|
-@pytest.mark.django_db
|
|
|
-def test_scrobble_mopidy_track(
|
|
|
- client,
|
|
|
- mopidy_track,
|
|
|
- valid_auth_token,
|
|
|
- seconds,
|
|
|
- expected_percent_played,
|
|
|
- expected_scrobble_id,
|
|
|
-):
|
|
|
- url = reverse("scrobbles:mopidy-webhook")
|
|
|
- headers = {"Authorization": f"Token {valid_auth_token}"}
|
|
|
-
|
|
|
- # Start new scrobble
|
|
|
- minutes = 0
|
|
|
- calc_seconds = seconds
|
|
|
- if seconds >= 60:
|
|
|
- minutes = 1
|
|
|
- calc_seconds = calc_seconds % 10
|
|
|
- with time_machine.travel(datetime(2024, 1, 14, 12, minutes, calc_seconds)):
|
|
|
- mopidy_track.request_data["playback_time_ticks"] = seconds * 1000
|
|
|
- response = client.post(
|
|
|
- url,
|
|
|
- mopidy_track.request_json,
|
|
|
- content_type="application/json",
|
|
|
- headers=headers,
|
|
|
- )
|
|
|
- assert response.status_code == 200
|
|
|
- assert response.data == {"scrobble_id": expected_scrobble_id}
|
|
|
-
|
|
|
- scrobble = Scrobble.objects.get(id=1)
|
|
|
- assert scrobble.percent_played == expected_percent_played
|
|
|
- assert scrobble.media_obj.__class__ == Track
|
|
|
- assert scrobble.media_obj.title == "Same in the End"
|
|
|
-
|
|
|
-
|
|
|
-# @pytest.mark.skip(reason="Allmusic API is unstable")
|
|
|
@pytest.mark.django_db
|
|
|
@patch("music.utils.lookup_artist_from_mb", return_value={})
|
|
|
@patch(
|
|
@@ -128,12 +81,13 @@ def test_scrobble_mopidy_same_track_different_album(
|
|
|
assert scrobble.media_obj.title == "Same in the End"
|
|
|
|
|
|
|
|
|
-@pytest.mark.skip(
|
|
|
- "Need to add a mock podcast request data, tho Google Podcasts is gone :thinking:"
|
|
|
-)
|
|
|
@pytest.mark.django_db
|
|
|
+@patch(
|
|
|
+ "podcasts.sources.podcastindex.lookup_podcast_from_podcastindex",
|
|
|
+ return_value={},
|
|
|
+)
|
|
|
def test_scrobble_mopidy_podcast(
|
|
|
- client, mopidy_podcast_request_data, valid_auth_token
|
|
|
+ mock_lookup_podcast, client, mopidy_podcast_request_data, valid_auth_token
|
|
|
):
|
|
|
url = reverse("scrobbles:mopidy-webhook")
|
|
|
headers = {"Authorization": f"Token {valid_auth_token}"}
|