historical_trainmap/tests.py

35 lines
893 B
Python
Raw Normal View History

2024-01-16 00:58:56 +00:00
from trainmap_backup import \
2024-01-16 01:31:03 +00:00
camel_to_snake, transform_dict, VERBATIM_KEY, VERBATIM_VALUE, DISCARD
2024-01-16 00:58:56 +00:00
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,
2024-01-16 01:31:03 +00:00
"otherkey": ("newkey", VERBATIM_VALUE),
"uppervalue": (VERBATIM_KEY, str.upper),
"retainboth": (VERBATIM_KEY, VERBATIM_VALUE)
2024-01-16 00:58:56 +00:00
},
{
"discard": True,
"passthrough": True,
"otherkey": True,
"uppervalue": "value",
"retainboth": "value",
}
) == {
"passthrough": True,
"newkey": True,
"uppervalue": "VALUE",
"retainboth": "value",
}