We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5a3eee commit c8e6244Copy full SHA for c8e6244
tests/test_struct.py
@@ -0,0 +1,22 @@
1
+import json
2
+
3
+from betterproto.lib.google.protobuf import Struct
4
5
6
+def test_struct_roundtrip():
7
+ data = {
8
+ "foo": "bar",
9
+ "baz": None,
10
+ "quux": 123,
11
+ "zap": [1, {"two": 3}, "four"],
12
+ }
13
+ data_json = json.dumps(data)
14
15
+ struct_from_dict = Struct().from_dict(data)
16
+ assert struct_from_dict.fields == data
17
+ assert struct_from_dict.to_json() == data_json
18
19
+ struct_from_json = Struct().from_json(data_json)
20
+ assert struct_from_json.fields == data
21
+ assert struct_from_json == struct_from_dict
22
+ assert struct_from_json.to_json() == data_json
0 commit comments