Beispiel #1
0
 def test_decode(self):
     instance = DummyClass()
     index_instance = InstanceIndex.encode(instance)
     index_instance['docnum'] = 1234
     decoded_instance = InstanceIndex.decode(index_instance)
     assert_is_instance(decoded_instance, DummyClass)
     assert_is_instance(decoded_instance.ipv4network, IPv4Network)
     assert_equals(decoded_instance.ipv4network.exploded, u'1.2.3.0/24')
     assert_equals(id(instance), id(decoded_instance))
     assert_equals(instance.unicode, decoded_instance.unicode)
     assert_equals(instance.string, decoded_instance.string)
     assert_equals(instance.integer, decoded_instance.integer)
     assert_equals(instance.float, decoded_instance.float)
     assert_equals(instance.datetime, decoded_instance.datetime)
     assert_equals(instance.ipv4network, decoded_instance.ipv4network)
Beispiel #2
0
 def test_encode(self):
     instance = DummyClass()
     assert_false(hasattr(instance, InstanceIndex.cache_property))
     index_instance = InstanceIndex.encode(instance)
     assert_is_instance(index_instance, dict)
     # assert_is_instance(index_instance['ipv4network'], unicode)
     assert_in(InstanceIndex.cache_property, index_instance.keys())