コード例 #1
0
ファイル: clazz_test.py プロジェクト: Manduka/soaplib
    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)
コード例 #2
0
ファイル: primitive_test.py プロジェクト: pfw/soaplib
 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])
コード例 #3
0
 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])
コード例 #4
0
    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)
コード例 #5
0
ファイル: test_primitive.py プロジェクト: baxeico/soaplib
    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)
コード例 #6
0
ファイル: clazz_test.py プロジェクト: Manduka/soaplib
    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))
コード例 #7
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))