mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Config] Fix get() functionality (#815)
This commit is contained in:
parent
68bc6e3325
commit
422bbba7f6
@ -443,10 +443,10 @@ class Config(BaseConfig):
|
||||
:return:
|
||||
"""
|
||||
|
||||
try:
|
||||
return getattr(self, key)(default=default)
|
||||
except AttributeError:
|
||||
return
|
||||
if default is not None:
|
||||
return self._get_value_from_key(key)(default)
|
||||
else:
|
||||
return self._get_value_from_key(key)()
|
||||
|
||||
async def set(self, key, value):
|
||||
# Notice to future developers:
|
||||
|
||||
@ -18,7 +18,7 @@ def json_driver(tmpdir_factory):
|
||||
return driver
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture()
|
||||
def config(json_driver):
|
||||
return Config(
|
||||
cog_name="PyTest",
|
||||
@ -26,7 +26,7 @@ def config(json_driver):
|
||||
driver_spawn=json_driver)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture()
|
||||
def config_fr(json_driver):
|
||||
"""
|
||||
Mocked config object with force_register enabled.
|
||||
|
||||
@ -145,3 +145,18 @@ async def test_set_channel_no_register(config, empty_channel):
|
||||
await config.channel(empty_channel).set("no_register", True)
|
||||
assert config.channel(empty_channel).no_register() is True
|
||||
#endregion
|
||||
|
||||
|
||||
# region Getting Values
|
||||
def test_get_func_w_reg(config):
|
||||
config.register_global(
|
||||
thing=True
|
||||
)
|
||||
assert config.get("thing") is True
|
||||
assert config.get("thing", False) is False
|
||||
|
||||
|
||||
def test_get_func_wo_reg(config):
|
||||
assert config.get("thing") is None
|
||||
assert config.get("thing", True) is True
|
||||
# endregion
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user