1
+ from dataclasses import dataclass
1
2
from test .unit .base import ClientBaseCase
2
3
3
- from linode_api4 .objects import Base , MappedObject , Property
4
+ from linode_api4 .objects import Base , JSONObject , MappedObject , Property
4
5
5
6
6
7
class MappedObjectCase (ClientBaseCase ):
@@ -20,7 +21,7 @@ def test_mapped_object_dict(self):
20
21
mapped_obj = MappedObject (** test_dict )
21
22
self .assertEqual (mapped_obj .dict , test_dict )
22
23
23
- def test_mapped_object_dict (self ):
24
+ def test_serialize_base_objects (self ):
24
25
test_property_name = "bar"
25
26
test_property_value = "bar"
26
27
@@ -42,3 +43,22 @@ class Foo(Base):
42
43
43
44
mapped_obj = MappedObject (foo = foo )
44
45
self .assertEqual (mapped_obj .dict , expected_dict )
46
+
47
+ def test_serialize_json_objects (self ):
48
+ test_property_name = "bar"
49
+ test_property_value = "bar"
50
+
51
+ @dataclass
52
+ class Foo (JSONObject ):
53
+ bar : str = ""
54
+
55
+ foo = Foo .from_json ({test_property_name : test_property_value })
56
+
57
+ expected_dict = {
58
+ "foo" : {
59
+ test_property_name : test_property_value ,
60
+ }
61
+ }
62
+
63
+ mapped_obj = MappedObject (foo = foo )
64
+ self .assertEqual (mapped_obj .dict , expected_dict )
0 commit comments