mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-06 14:24:30 +01:00
rename test file
This commit is contained in:
1 parent
a609652232
commit
3cc7e90a19
3 files changed
+98
No files matched your search
@@ -2,8 +2,10 @@
|
||||
from discord.ext import commands
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .localizer.localizerwrapper import LocalizerWrapper
|
||||
|
||||
|
||||
class LocalizedContext(commands.Context):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
from .dictmapper import DictMapper
|
||||
|
||||
|
||||
class TestDictMapper():
|
||||
def test_dict_mapper_basic_set(self):
|
||||
d = {}
|
||||
DictMapper.set(d, ["a", "b", "c"], 1)
|
||||
assert d == {"a": {"b": {"c": 1}}}
|
||||
|
||||
def test_dict_mapper_basic_get(self):
|
||||
d = {"a": {"b": {"c": 1}}}
|
||||
assert DictMapper.get(d, ["a", "b", "c"]) == 1
|
||||
|
||||
def test_get_variations(self):
|
||||
d = {"a": {"b": {"c": 1}}}
|
||||
|
||||
assert DictMapper.get(d, ["a", "b", "c"]) == DictMapper.get(d["a"], ["b", "c"])
|
||||
assert DictMapper.get(d, ["a", "b", "c"]) == DictMapper.get(d["a"]["b"], ["c"])
|
||||
assert DictMapper.get(d, ["a", "b", "c"]) == d["a"]["b"]["c"]
|
||||
|
||||
def test_get_sub_dictionaries(self):
|
||||
d = {"a": {"b": {"c": 1}}}
|
||||
assert DictMapper.get(d, ["a", "b"]) == d["a"]["b"]
|
||||
assert DictMapper.get(d["a"], ["b"]) == DictMapper.get(d["a"], ["b"])
|
||||
|
||||
def test_set_variation(self):
|
||||
d = {"a": {"b": {"c": 1}}}
|
||||
d1 = {}
|
||||
d2 = {}
|
||||
|
||||
DictMapper.set(d1, ["a", "b"], {"c": 1})
|
||||
assert d1 == d
|
||||
|
||||
DictMapper.set(d2, ["a"], {"b": {"c": 1}})
|
||||
assert d2 == d
|
||||
|
||||
def test_multiple_paths(self):
|
||||
d = {}
|
||||
|
||||
DictMapper.set(d, ["a", "b1", "c"], 1)
|
||||
DictMapper.set(d, ["a", "b1", "d"], 2)
|
||||
DictMapper.set(d, ["a", "b2", "c"], 3)
|
||||
DictMapper.set(d, ["a", "b2", "d"], 4)
|
||||
|
||||
expected = {
|
||||
"a": {
|
||||
"b1": {
|
||||
"c": 1,
|
||||
"d": 2,
|
||||
},
|
||||
"b2": {
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
assert d == expected
|
||||
|
||||
def test_overwrite(self):
|
||||
d = {}
|
||||
|
||||
DictMapper.set(d, ["a", "b1", "c"], 1)
|
||||
DictMapper.set(d, ["a", "b1", "d"], 2)
|
||||
DictMapper.set(d, ["a", "b2", "c"], 3)
|
||||
DictMapper.set(d, ["a", "b2", "d"], 4)
|
||||
|
||||
expected = {
|
||||
"a": {
|
||||
"b1": {
|
||||
"c": 1,
|
||||
"d": 2,
|
||||
},
|
||||
"b2": {
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
assert d == expected
|
||||
|
||||
DictMapper.set(d, ["a", "b2"], 4)
|
||||
expected = {
|
||||
"a": {
|
||||
"b1": {
|
||||
"c": 1,
|
||||
"d": 2,
|
||||
},
|
||||
"b2": 4,
|
||||
}
|
||||
}
|
||||
assert d == expected
|
||||
@@ -89,3 +89,8 @@ class TestDictMapper():
|
||||
}
|
||||
}
|
||||
assert d == expected
|
||||
|
||||
|
||||
@patch
|
||||
class TestSettingsManager:
|
||||
def test_
|
||||
Reference in new issue
Block a user