matchy/tests/util_test.py
Marc Di Luzio f926a36069
Some checks failed
Test, Build and Publish / test (push) Has been cancelled
Test, Build and Publish / build-and-push-images (push) Has been cancelled
Fix /leave not working for anyone who's paused in the past
We now clear the re-activate value when a user is unpaused.

Added bonus here is various bits of refactor and cleanup, with some tests
2024-08-17 14:14:45 +01:00

40 lines
894 B
Python

import matchy.util as util
def test_iterate_all_shifts():
original = [1, 2, 3, 4]
lists = [val for val in util.iterate_all_shifts(original)]
assert lists == [
[1, 2, 3, 4],
[2, 3, 4, 1],
[3, 4, 1, 2],
[4, 1, 2, 3],
]
def test_get_nested_dict_value():
d = {
"x": {
"y": {
"z": {
"val": 42
}
}
}
}
assert 42 == util.get_nested_value(d, "x", "y", "z", "val")
assert 16 == util.get_nested_value(d, "x", "y", "z", "vol", default=16)
def test_set_nested_dict_value():
d = {
"x": {
"y": {
"z": {
"val": 42
}
}
}
}
util.set_nested_value(d, "x", "y", "z", "val", value=52)
assert 52 == util.get_nested_value(d, "x", "y", "z", "val")