def test_it_raises_database_exceptions_if_something_goes_wrong(self, mock_db_connect): with self.assertRaises(DatabaseException): db_user_timeline_event.create_user_timeline_event( user_id=self.user['id'], event_type=UserTimelineEventType.RECORDING_RECOMMENDATION, metadata=RecordingRecommendationMetadata( track_name="Sunflower", artist_name="Swae Lee & Post Malone", recording_msid=str(uuid.uuid4()), ) )
def test_it_adds_rows_to_the_database(self): event = db_user_timeline_event.create_user_timeline_event( user_id=self.user['id'], event_type=UserTimelineEventType.RECORDING_RECOMMENDATION, metadata=RecordingRecommendationMetadata( track_name="Sunflower", artist_name="Swae Lee & Post Malone", recording_msid=str(uuid.uuid4()), artist_msid=str(uuid.uuid4()), )) events = db_user_timeline_event.get_user_track_recommendation_events( user_id=self.user['id'], count=1, ) self.assertEqual(1, len(events)) self.assertEqual(event.id, events[0].id) self.assertEqual(event.created, events[0].created) self.assertEqual('Sunflower', events[0].metadata.track_name)