MCPcopy Create free account
hub / github.com/StackStorm/st2 / test_roundtrip

Method test_roundtrip

st2common/tests/unit/test_db_fields.py:108–123  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

106 self.assertEqual(result, MOCK_DATA_DICT)
107
108 def test_roundtrip(self):
109 field = JSONDictField(use_header=False)
110 result_to_mongo = field.to_mongo(MOCK_DATA_DICT)
111 result_to_python = field.to_python(result_to_mongo)
112
113 self.assertEqual(result_to_python, MOCK_DATA_DICT)
114
115 # sets get serialized to a list
116 input_dict = {"a": 1, "set": {1, 2, 3, 4, 4, 4, 5, 5}}
117 result = {"a": 1, "set": [1, 2, 3, 4, 5]}
118
119 field = JSONDictField(use_header=False)
120 result_to_mongo = field.to_mongo(input_dict)
121 result_to_python = field.to_python(result_to_mongo)
122
123 self.assertEqual(result_to_python, result)
124
125 def test_parse_field_value(self):
126 # 1. Value not provided, should use default one

Callers

nothing calls this directly

Calls 3

to_mongoMethod · 0.95
to_pythonMethod · 0.95
JSONDictFieldClass · 0.90

Tested by

no test coverage detected