示例#1
0
def get_kind_mapping():
    """
    Get a mapping of kinds

    Returns:
        dict: A map of the kind name to the kind prefix (ie t1)
    """
    return Config("DEFAULT").kinds
示例#2
0
 def test_extended_interpolation(self):
     Config.CONFIG = None  # Force config file reload
     with mock.patch.dict(
         "os.environ",
         {
             "APPDATA": os.path.dirname(__file__),
             "XDG_CONFIG_HOME": os.path.dirname(__file__),
         },
     ):
         config = Config("INTERPOLATION", config_interpolation="extended")
         assert config.custom["basic_interpolation"] == "%(reddit_url)s"
         assert config.custom["extended_interpolation"] == config.reddit_url
示例#3
0
 def test_short_url_not_defined(self):
     config = Config('DEFAULT', short_url=None)
     with pytest.raises(ClientException) as excinfo:
         config.short_url
     assert str(excinfo.value) == 'No short domain specified.'
示例#4
0
 def test_short_url(self):
     config = Config('DEFAULT')
     assert config.short_url == 'https://redd.it'
示例#5
0
 def test_check_for_updates__true(self):
     for value in [True, '1', 'true', 'YES', 'on']:
         config = Config('DEFAULT', check_for_updates=value)
         assert config.check_for_updates is True
示例#6
0
 def test_custom__no_extra_values_set(self):
     config = Config('DEFAULT')
     assert config.custom == {}
示例#7
0
 def test_custom__extra_values_set(self):
     config = Config('DEFAULT', user1='foo', user2='bar')
     assert config.custom == {'user1': 'foo', 'user2': 'bar'}
示例#8
0
 def test_check_for_updates__false(self):
     for value in [False, 'False', 'other']:
         config = Config('DEFAULT', check_for_updates=value)
         assert config.check_for_updates is False
示例#9
0
 def test_unset_value_has_useful_string_representation(self):
     config = Config('DEFAULT', password=Config.CONFIG_NOT_SET)
     assert str(config.password) == 'NotSet'
示例#10
0
 def test_short_url(self):
     config = Config("DEFAULT")
     assert config.short_url == "https://redd.it"
示例#11
0
 def test_check_for_updates__true(self):
     for value in [True, "1", "true", "YES", "on"]:
         config = Config("DEFAULT", check_for_updates=value)
         assert config.check_for_updates is True
示例#12
0
 def test_custom__extra_values_set(self):
     config = Config("DEFAULT", user1="foo", user2="bar")
     assert config.custom == {"user1": "foo", "user2": "bar"}
示例#13
0
 def test_check_for_updates__false(self):
     for value in [False, "False", "other"]:
         config = Config("DEFAULT", check_for_updates=value)
         assert config.check_for_updates is False
示例#14
0
 def test_store_json__true(self):
     for value in [True, '1', 'true', 'YES', 'on']:
         config = Config('DEFAULT', store_json=value)
         assert config.store_json is True
示例#15
0
 def test_store_json__false(self):
     for value in [False, 'False', 'other']:
         config = Config('DEFAULT', store_json=value)
         assert config.store_json is False