Skip to content

Commit

Permalink
add drop key tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-ranff committed Mar 15, 2023
1 parent 83d2c77 commit bf4f5d3
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions tests/test_drop_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import uparma
import pytest


test_data_list = [
{
"input": {
("general", "parameters"): [
{
"name": "to_key_or_not_to_key",
"key_translations": {
"ursgal_style_1": "to_key_or_not_to_key",
"some_other_style": "to_key_or_not_to_key_<DROP_KEY>",
},
"value_translations": {
"ursgal_style_1": [[True, True], [False, False]],
"some_other_style": [[True, "i_lived"], [False, "i_died"]],
},
},
{
"name": "to_key_or_not_to_key_list",
"key_translations": {
"ursgal_style_1": "to_key_or_not_to_key_list",
"some_other_style": [
"keyp_no_pun_intended",
"to_key_or_not_to_key_<DROP_KEY>",
],
},
"value_translations": {
"ursgal_style_1": [[True, True], [False, False]],
"some_other_style": [[True, "i_lived"], [False, "i_died"]],
},
},
{
"name": "to_key_or_not_to_key_rip_delim",
"key_translations": {
"ursgal_style_1": "to_key_or_not_to_key_rip_delim",
"some_other_style": "to_key_or_not_to_key_DROP_KEY",
},
"value_translations": {
"ursgal_style_1": [[True, True], [False, False]],
"some_other_style": [[True, "i_lived"], [False, "i_died"]],
},
},
]
},
}
]


@pytest.mark.parametrize("test_dict", test_data_list)
def test_load_data(test_dict):
up = uparma.UParma(refresh_jsons=False, parameter_data=test_dict["input"])
translation = up.convert(
{
"to_key_or_not_to_key": True,
"to_key_or_not_to_key_list": False,
"to_key_or_not_to_key_rip_delim": False,
},
"some_other_style",
)
assert translation["to_key_or_not_to_key"]["translated_key"] is None
assert translation["to_key_or_not_to_key"]["translated_value"] == "i_lived"
assert translation["to_key_or_not_to_key_list"]["translated_key"] == [
"keyp_no_pun_intended",
None,
]
assert translation["to_key_or_not_to_key_list"]["translated_value"] == "i_died"
assert (
translation["to_key_or_not_to_key_rip_delim"]["translated_key"]
== "to_key_or_not_to_key_DROP_KEY"
)
assert translation["to_key_or_not_to_key_rip_delim"]["translated_value"] == "i_died"

0 comments on commit bf4f5d3

Please sign in to comment.