Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai committed Apr 17, 2024
1 parent f479c3e commit c8b3e43
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/unit/objects/mapped_object_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from test.unit.base import ClientBaseCase

from linode_api4.objects import Base, MappedObject, Property
from linode_api4.objects import Base, JSONObject, MappedObject, Property


class MappedObjectCase(ClientBaseCase):
Expand All @@ -20,7 +21,7 @@ def test_mapped_object_dict(self):
mapped_obj = MappedObject(**test_dict)
self.assertEqual(mapped_obj.dict, test_dict)

def test_mapped_object_dict(self):
def test_base_objects_serialize(self):
test_property_name = "bar"
test_property_value = "bar"

Expand All @@ -42,3 +43,22 @@ class Foo(Base):

mapped_obj = MappedObject(foo=foo)
self.assertEqual(mapped_obj.dict, expected_dict)

def test_json_objects_serialize(self):
test_property_name = "bar"
test_property_value = "bar"

@dataclass
class Foo(JSONObject):
bar: str = ""

foo = Foo.from_json({test_property_name: test_property_value})

expected_dict = {
"foo": {
test_property_name: test_property_value,
}
}

mapped_obj = MappedObject(foo=foo)
self.assertEqual(mapped_obj.dict, expected_dict)

0 comments on commit c8b3e43

Please sign in to comment.