historical_trainmap/tests.py

35 lines
893 B
Python

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