historical_trainmap/tests.py
Midgard b1740e6667
Remove fancy JsonRoundingFloat and JsonLatLon
because the Python JSON lib can't override the precise serialization
anyway. Ugh.
2024-01-16 02:30:34 +01:00

36 lines
933 B
Python

from trainmap_backup import \
camel_to_snake, transform_dict, RETAIN_KEY, RETAIN_VALUE, DISCARD, \
JsonRoundingFloat, JsonLonLatCoord, json_encode
def test_camel_to_snake():
assert camel_to_snake("testcase") == "testcase"
assert camel_to_snake("test_case") == "test_case"
assert camel_to_snake("Testcase") == "testcase"
assert camel_to_snake("TestCase") == "test_case"
assert camel_to_snake("AnotherTestCase") == "another_test_case"
assert camel_to_snake("Test_Case") == "test__case"
def test_transform_dict():
assert transform_dict(
{
"discard": DISCARD,
"otherkey": ("newkey", RETAIN_VALUE),
"uppervalue": (RETAIN_KEY, str.upper),
"retainboth": (RETAIN_KEY, RETAIN_VALUE)
},
{
"discard": True,
"passthrough": True,
"otherkey": True,
"uppervalue": "value",
"retainboth": "value",
}
) == {
"passthrough": True,
"newkey": True,
"uppervalue": "VALUE",
"retainboth": "value",
}