mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 18:06:08 -05:00
[Config] Cast keys to str on get/set/clear (#2217)
This is a step towards a more consistent front-end behaviour of Config, where errors are either circumvented or raised in the same way regardless of the driver being used. Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
@@ -475,3 +475,18 @@ async def test_get_raw_mixes_defaults(config):
|
||||
|
||||
subgroup = await config.get_raw("subgroup")
|
||||
assert subgroup == {"foo": True, "bar": False}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cast_str_raw(config):
|
||||
await config.set_raw(123, 456, value=True)
|
||||
assert await config.get_raw(123, 456) is True
|
||||
assert await config.get_raw("123", "456") is True
|
||||
await config.clear_raw("123", 456)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cast_str_nested(config):
|
||||
config.register_global(foo={})
|
||||
await config.foo.set({123: True, 456: {789: False}})
|
||||
assert await config.foo() == {"123": True, "456": {"789": False}}
|
||||
|
||||
Reference in New Issue
Block a user