Beispiel #1
0
    def test_prepare_playback_raises_paramater_missing(self):
        with patch.object(plm.PlaylistModel, 'prepare_playback') as super_mock:

            self.result.register_ad = Mock(side_effect=ParameterMissing(
                'No ad tracking tokens provided for registration.'))
            self.assertRaises(ParameterMissing, self.result.prepare_playback)
            assert self.result.register_ad.called
            assert not super_mock.called
Beispiel #2
0
    def test_prepare_playback_handles_paramater_missing_if_no_tokens(self):
        with patch.object(plm.PlaylistModel, 'prepare_playback') as super_mock:

            self.result.tracking_tokens = []
            self.result.register_ad = Mock(side_effect=ParameterMissing(
                'No ad tracking tokens provided for registration.'))
            self.result.prepare_playback()
            assert self.result.register_ad.called
            assert super_mock.called
Beispiel #3
0
    def test_reraise_missing_params_exception(self):
        plmock = patch.object(APIClient,
                              'get_playlist',
                              side_effect=ParameterMissing("ParameterMissing"))

        with plmock as get_playlist_mock:
            with self.assertRaises(ParameterMissing):
                station = Station.from_json(self.client,
                                            {'stationToken': 'token_mock'})
                track_mock = PlaylistItem.from_json(self.client,
                                                    {'token': 'token_mock'})
                get_playlist_mock.return_value = iter([track_mock])

                station_iter = iterate_forever(station.get_playlist)
                next(station_iter)
Beispiel #4
0
    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)