Esempio n. 1
0
 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')
Esempio n. 2
0
    def test_config_written_with_dict(self):
        from tekore.util import config
        written = {config.client_secret_var: 'secret'}

        config_to_file(self.test_config_path, written)
        loaded = config_from_file(self.test_config_path)
        self.assertTupleEqual((None, 'secret', None), loaded)
Esempio n. 3
0
    def test_config_tuple_nones_not_written(self):
        original = ('id', 'secret', 'uri')
        config_to_file(self.test_config_path, original)

        written = (None, 'another', None)
        config_to_file(self.test_config_path, written)

        loaded = config_from_file(self.test_config_path)
        self.assertTupleEqual(('id', 'another', 'uri'), loaded)
Esempio n. 4
0
 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))
Esempio n. 5
0
 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))
Esempio n. 6
0
    def test_file_another_section(self):
        self._config_names_set(
            'CLIENT_ID',
            'CLIENT_SECRET',
            'REDIRECT_URI',
            '_'
        )

        conf = config_from_file(self.test_config_path, 'ANOTHER')
        self.assertTupleEqual(conf, ('an_id', 'an_secret', 'an_uri'))
Esempio n. 7
0
 def test_config_written_with_tuple_refresh_token(self):
     written = ('id', 'secret', 'uri', 'refresh')
     config_to_file(self.test_config_path, written)
     loaded = config_from_file(self.test_config_path, return_refresh=True)
     self.assertTupleEqual(written, loaded)
Esempio n. 8
0
 def test_config_write_to_section(self):
     written = ('id', 'secret', 'uri')
     config_to_file(self.test_config_path, written, section='SEC')
     loaded = config_from_file(self.test_config_path, section='SEC')
     self.assertTupleEqual(written, loaded)
Esempio n. 9
0
 def test_config_written_with_tuple(self):
     written = ('id', 'secret', 'uri')
     config_to_file(self.test_config_path, written)
     loaded = config_from_file(self.test_config_path)
     self.assertTupleEqual(written, loaded)
Esempio n. 10
0
 def test_file_pathlib_path_accepted(self):
     from pathlib import Path
     path = Path(self.test_config_path)
     conf = config_from_file(path)
     self.assertTupleEqual(conf, ('df_id', 'df_secret', 'df_uri'))
Esempio n. 11
0
 def test_file_nonexistent_section_raises(self):
     with self.assertRaises(KeyError):
         config_from_file(self.test_config_path, 'NOTSECTION')
Esempio n. 12
0
 def test_file_nonexistent_file_raises(self):
     with self.assertRaises(FileNotFoundError):
         config_from_file('not_file.ini')
Esempio n. 13
0
 def test_file_refresh_returned(self):
     conf = config_from_file(self.test_config_path, return_refresh=True)
     self.assertTupleEqual(conf,
                           ('df_id', 'df_secret', 'df_uri', 'df_refresh'))
Esempio n. 14
0
 def test_file_default_section(self):
     conf = config_from_file(self.test_config_path)
     self.assertTupleEqual(conf, ('df_id', 'df_secret', 'df_uri'))