def ad_item_mock(): ad_item = AdItem.from_json( get_backend(config()).api, ad_metadata_result_mock()['result']) ad_item.station_id = MOCK_STATION_ID ad_item.ad_token = MOCK_TRACK_AD_TOKEN return ad_item
def test_handle_missing_params_exception_due_to_missing_ad_tokens(self): with patch.object(APIClient, 'get_playlist') as get_playlist_mock: with patch.object(APIClient, 'register_ad', side_effect=ParameterMissing("ParameterMissing")): station = Station.from_json(self.client, {'stationToken': 'token_mock'}) ad_mock = AdItem.from_json(self.client, {'station_id': 'id_mock'}) get_playlist_mock.return_value=iter([ad_mock]) station_iter = iterate_forever(station.get_playlist) next_track = next(station_iter) self.assertEqual(ad_mock, next_track)
def test_handle_missing_params_exception_due_to_missing_ad_tokens(self): with patch.object(APIClient, 'get_playlist') as get_playlist_mock: with patch.object( APIClient, 'register_ad', side_effect=ParameterMissing("ParameterMissing")): station = Station.from_json(self.client, {'stationToken': 'token_mock'}) ad_mock = AdItem.from_json(self.client, {'station_id': 'id_mock'}) get_playlist_mock.return_value = iter([ad_mock]) station_iter = iterate_forever(station.get_playlist) next_track = next(station_iter) self.assertEqual(ad_mock, next_track)
def ad_item_mock(config, ad_metadata_result_mock): ad_item = AdItem.from_json(get_backend( config).api, ad_metadata_result_mock['result']) ad_item.station_id = MOCK_STATION_ID ad_item.ad_token = MOCK_TRACK_AD_TOKEN return ad_item
def setUp(self): api_client_mock = Mock(spec=APIClient) api_client_mock.default_audio_quality = APIClient.HIGH_AUDIO_QUALITY self.result = AdItem.from_json(api_client_mock, self.JSON_DATA) self.result.station_id = 'station_id_mock' self.result.ad_token = 'token_mock'