def test_update_with_lists(self): org = AdJson() org.a = [1, 2, {'a': 'superman'}] someother = AdJson() someother.b = [{'b': 123}] org.update(someother) correct = {'a': [1, 2, {'a': 'superman'}], 'b': [{'b': 123}]} org.update(someother) self.assert_ad_json_equal(org, correct) self.assertIsInstance(org.b[0].to_dict(), dict)
def test_update(self): old = AdJson() old.child.a = 'a' old.child.b = 'b' old.foo = 'c' new = AdJson() new.child.b = 'b2' new.child.c = 'c' new.foo.bar = True old.update(new) reference = {'foo': {'bar': True}, 'child': {'a': 'a', 'c': 'c', 'b': 'b2'}} self.assert_ad_json_equal(old, reference)
def test_update_with_args_and_kwargs(self): expected = {'a': 1, 'b': 2} org = AdJson() org.update({'a': 3, 'b': 2}, a=1) self.assert_ad_json_equal(org, expected)
def test_update_with_kws(self): org = AdJson(one=1, two=2) someother = AdJson(one=3) someother.update(one=1, two=2) self.assert_ad_json_equal(org, someother)