def test_class_nested_array(self): peeps = [] names = ['bob', 'jim', 'peabody', 'mumblesleves'] for name in names: a = Person() a.name = name a.birthdate = datetime.datetime(1979, 1, 1) a.age = 27 a.addresses = [] for i in range(0, 25): addr = Address() addr.street = '555 downtown' addr.city = 'funkytown' a.addresses.append(addr) peeps.append(a) serializer = Array(Person) element = serializer.to_xml(peeps) self.assertEquals(4, len(element.getchildren())) peeps2 = serializer.from_xml(element) for peep in peeps2: self.assertEquals(27, peep.age) self.assertEquals(25, len(peep.addresses)) self.assertEquals('funkytown', peep.addresses[18].city)
def test_array(self): serializer = Array(String) values = ['a', 'b', 'c', 'd', 'e', 'f'] element = serializer.to_xml(values) self.assertEquals(len(values), len(element.getchildren())) values2 = serializer.from_xml(element) self.assertEquals(values[3], values2[3])
def test_array(self): serializer = Array(String) values = ['a', 'b', 'c', 'd', 'e', 'f'] element = serializer.to_xml(values) self.assertEquals(len(values), len(element.getchildren())) values2 = serializer.from_xml(element) self.assertEquals(values[3], values2[3])
def test_class_nested_array(self): peeps = [] names = ['bob', 'jim', 'peabody', 'mumblesleves'] for name in names: a = Person() a.name = name a.birthdate = datetime.datetime(1979, 1, 1) a.age = 27 a.addresses = [] for i in range(0, 25): addr = Address() addr.street = '555 downtown' addr.city = 'funkytown' a.addresses.append(addr) peeps.append(a) serializer = Array(Person) element = serializer.to_xml(peeps) self.assertEquals(4, len(element.getchildren())) peeps2 = serializer.from_xml(element) for peep in peeps2: self.assertEquals(27, peep.age) self.assertEquals(25, len(peep.addresses)) self.assertEquals('funkytown', peep.addresses[18].city)
def test_array_empty(self): serializer = Array(String) serializer.resolve_namespace("zbank") values = [] element = serializer.to_xml(values, ns_test) self.assertEquals(len(values), len(element.getchildren())) values2 = serializer.from_xml(element) self.assertEquals(len(values2), 0)
def test_class_array(self): peeps = [] names = ['bob', 'jim', 'peabody', 'mumblesleves'] for name in names: a = Person() a.name = name a.birthdate = datetime.datetime(1979, 1, 1) a.age = 27 peeps.append(a) serializer = Array(Person) element = serializer.to_xml(peeps) self.assertEquals(4, len(element.getchildren())) peeps2 = serializer.from_xml(element) for i in range(0, 4): self.assertEquals(peeps[i].name, names[i]) self.assertEquals(peeps[i].birthdate, datetime.datetime(1979, 1, 1))
def test_class_array(self): peeps = [] names = ['bob', 'jim', 'peabody', 'mumblesleves'] for name in names: a = Person() a.name = name a.birthdate = datetime.datetime(1979, 1, 1) a.age = 27 peeps.append(a) serializer = Array(Person) element = serializer.to_xml(peeps) self.assertEquals(4, len(element.getchildren())) peeps2 = serializer.from_xml(element) for i in range(0, 4): self.assertEquals(peeps[i].name, names[i]) self.assertEquals(peeps[i].birthdate, datetime.datetime(1979, 1, 1))