Example #1
0
 def test_lists(self):
     kobj = KadetTestObj(name="testObj", size=5)
     kobj.root.with_lists = [
         Dict({"i_am_inside_a_list": True}),
         BaseObj.from_dict({"me": "too"}),
         BaseObj.from_dict({
             "list_of_objs":
             [BaseObj.from_dict(dict(a=1, b=2)),
              Dict(dict(c=3, d=4))]
         }),
     ]
     output = kobj.to_dict()
     desired_output = {
         "name":
         "testObj",
         "size":
         5,
         "first_key":
         1,
         "traditional_key":
         3,
         "nested": {
             "first_key": 2
         },
         "with_dict": {
             "A": "dict"
         },
         "with_baseobj_init_as": {
             "init": "as"
         },
         "with_baseobj": {
             "inside": "BaseObj"
         },
         "with_another_dict": {
             "Another": "Dict"
         },
         "with_lists": [
             {
                 "i_am_inside_a_list": True
             },
             {
                 "me": "too"
             },
             {
                 "list_of_objs": [{
                     "a": 1,
                     "b": 2
                 }, {
                     "c": 3,
                     "d": 4
                 }]
             },
         ],
     }
     self.assertEqual(output, desired_output)
Example #2
0
 def body(self):
     self.root.name = self.kwargs.name
     self.root.size = self.kwargs.size
     self.root.first_key = 1
     self.root.nested.first_key = 2
     self.root['traditional_key'] = 3
     self.root.with_dict = {'A': 'dict'}
     self.root.with_baseobj_init_as = BaseObj.from_dict({'init': 'as'})
     bobj = BaseObj()
     bobj.root.inside = "BaseObj"
     self.root.with_baseobj = bobj
     self.root.with_another_dict = Dict({'Another': 'Dict'})
Example #3
0
 def body(self):
     self.root.name = self.kwargs.name
     self.root.size = self.kwargs.size
     self.root.first_key = 1
     self.root.nested.first_key = 2
     self.root["traditional_key"] = 3
     self.root.with_dict = {"A": "dict"}
     self.root.with_baseobj_init_as = BaseObj.from_dict({"init": "as"})
     bobj = BaseObj()
     bobj.root.inside = "BaseObj"
     self.root.with_baseobj = bobj
     self.root.with_another_dict = Dict({"Another": "Dict"})
Example #4
0
 def test_parse_kwargs(self):
     kobj = BaseObj.from_dict({"this": "that", "not_hidden": True})
     output = kobj.to_dict()
     desired_output = {"this": "that", "not_hidden": True}
     self.assertEqual(output, desired_output)