def setUpClass(cls): super().setUpClass() tracks = cls.client.playlist_tracks('37i9dQZF1DX5Ejj0EkURtP') cls.track_ids = [t.track.id for t in tracks.items] cls.handle = handle_warnings() cls.handle.__enter__()
def test_config_written_with_dict(self, conf_path): import tekore as tk written = {tk.client_secret_var: 'secret'} config_to_file(conf_path, written) with handle_warnings('ignore'): loaded = config_from_file(conf_path) assert (None, 'secret', None) == loaded
def setUpClass(cls): super().setUpClass() cls.aclient = Spotify(cls.user_token, asynchronous=True) cls.tracks = cls.client.album_tracks(album_id, limit=1) cls.played = cls.client.playback_recently_played() cls.handle = handle_warnings() cls.handle.__enter__()
def test_missing_variables_warned(self): self._config_names_set( 'CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI', '_' ) with handle_warnings('error'): with self.assertRaises(MissingConfigurationWarning): config_from_file(self.test_config_path, 'MISSING')
def test_file_another_section_is_case_sensitive(self): self._config_names_set( 'client_id', 'client_secret', 'redirect_uri', '_' ) with handle_warnings('ignore'): conf = config_from_file(self.test_config_path) self.assertTupleEqual(conf, (None, None, None))
def test_file_missing_variables_returns_none(self): self._config_names_set( 'CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI', '_' ) with handle_warnings('ignore'): conf = config_from_file(self.test_config_path, 'MISSING') self.assertTupleEqual(conf, (None, None, None))
def test_sender_conflict_issues_warning(self): with handle_warnings('error'): with pytest.raises(SenderConflictWarning): self._client(True, False)
def test_async_sender_conflict_resolved_to_asynchronous_argument(self): with handle_warnings(): c = self._client(True, False) assert c.is_async is False
def test_sync_sender_conflict_resolved_to_asynchronous_argument(self): with handle_warnings(): c = self._client(False, True) self.assertTrue(c.is_async)
def suppress_warnings(): with handle_warnings(): yield
def test_file_missing_variables_returns_none(self, conf_path): config_names_set('CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI', '_') with handle_warnings('ignore'): conf = config_from_file(conf_path, 'MISSING') assert conf == (None, None, None)
def test_missing_variables_warned(self, conf_path): config_names_set('CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI', '_') with handle_warnings('error'): with pytest.raises(MissingConfigurationWarning): config_from_file(conf_path, 'MISSING')
def test_file_another_section_is_case_sensitive(self, conf_path): config_names_set('client_id', 'client_secret', 'redirect_uri', '_') with handle_warnings('ignore'): conf = config_from_file(conf_path) assert conf == (None, None, None)