Ejemplo n.º 1
0
 def test_tracks_adding(self):
     collection = TracksCollection()
     self.assertEqual(collection.get_tracks(), set())
     track_a = self._create_test_track()
     track_b = self._create_test_track()
     collection.add_track(track_a)
     collection.add_track(track_b)
     self.assertEqual(collection.get_tracks(), {track_a, track_b})
     track_c = self._create_test_track()
     track_d = self._create_test_track()
     collection.add_tracks(
         TracksCollection().add_track(track_c).add_track(track_d))
     self.assertEqual(collection.get_tracks(),
                      {track_a, track_b, track_c, track_d})
Ejemplo n.º 2
0
 def test_save_recently_played_tracks_success(self):
     recently_played_tracks = TracksCollection()
     recently_played_tracks.add_track(self._create_test_track("test_track"))
     self.spotify_client_mock.get_recently_played_tracks.return_value = recently_played_tracks
     self.tracks_history_service.save_recently_played_tracks()
     self.tracks_repository_mock.save_tracks.assert_called_once_with([
         TrackRecord(id=track.id)
         for track in recently_played_tracks.get_tracks()
     ])
Ejemplo n.º 3
0
 def _tracks_to_track_records(tracks: TracksCollection) -> [TrackRecord]:
     return [TrackRecord(id=track.id) for track in tracks.get_tracks()]