Skip to content

Commit ff8d317

Browse files
chore: Add quote handling to conversion (#1064)
1 parent 9109c4d commit ff8d317

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/allotropy/allotrope/converter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
"^": "_CARET_",
107107
"=": "_EQUALS_",
108108
"@": "_AT_",
109+
"'": "_QUOTE_",
109110
# NOTE: this MUST be at the end, or it will break other key replacements.
110111
" ": "_",
111112
}

tests/allotrope/converter_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ def test_custom_information_document() -> None:
135135
cycle_threshold_value_setting=TQuantityValueUnitless(value=1.0),
136136
),
137137
),
138-
{"extra key": "Value", "weird-key/(value)°": "Other value"},
138+
{"extra key": "Value", "$w.e\\ir:[d]-k'e~y/(v^a=l@ue)°#": "Other value"},
139139
)
140140

141141
assert item.custom_information_document.extra_key == "Value" # type: ignore
142-
assert item.custom_information_document.weird_DASH_key_SLASH__OPAREN_value_CPAREN__DEG_ == "Other value" # type: ignore
142+
assert item.custom_information_document._DOLLAR_w_POINT_e_BSLASH_ir_COLON__OBRACKET_d_CBRACKET__DASH_k_QUOTE_e_TILDE_y_SLASH__OPAREN_v_CARET_a_EQUALS_l_AT_ue_CPAREN__DEG__NUMBER_ == "Other value" # type: ignore
143143
asm_dict = unstructure(item)
144144
assert asm_dict == {
145145
"cycle threshold result": {"value": None, "unit": "(unitless)"},
@@ -148,7 +148,7 @@ def test_custom_information_document() -> None:
148148
},
149149
"custom information document": {
150150
"extra key": "Value",
151-
"weird-key/(value)°": "Other value",
151+
"$w.e\\ir:[d]-k'e~y/(v^a=l@ue)°#": "Other value",
152152
},
153153
}
154154
assert structure(asm_dict, ProcessedDataDocumentItem) == item

0 commit comments

Comments
 (0)