def test_boolean(self): b = Boolean.to_xml(True) self.assertEquals('true', b.text) b = Boolean.to_xml(0) self.assertEquals('false', b.text) b = Boolean.to_xml(1) self.assertEquals('true', b.text) b = Boolean.from_xml(b) self.assertEquals(b, True) b = Boolean.to_xml(False) self.assertEquals('false', b.text) b = Boolean.from_xml(b) self.assertEquals(b, False) b = Boolean.to_xml(False) self.assertEquals('xs:boolean', b.get(ns.get('xsi') + 'type')) b = Boolean.to_xml(None) self.assertEquals('1', b.get(ns.get('xs') + 'nil')) b = Boolean.from_xml(b) self.assertEquals(b, None)
def test_boolean(self): b = Boolean.to_xml(True) self.assertEquals('true', b.text) b = Boolean.to_xml(0) self.assertEquals('false', b.text) b = Boolean.to_xml(1) self.assertEquals('true', b.text) b = Boolean.from_xml(b) self.assertEquals(b, True) b = Boolean.to_xml(False) self.assertEquals('false', b.text) b = Boolean.from_xml(b) self.assertEquals(b, False) b = Boolean.to_xml(False) self.assertEquals('xs:boolean', b.get(ns.get('xsi') + 'type')) b = Boolean.to_xml(None) self.assertEquals('1', b.get(ns.get('xs') + 'null')) b = Boolean.from_xml(b) self.assertEquals(b, None)
def test_schema(self): a = {} Person.add_to_schema(a, NamespaceLookup()) #self.assertEquals(8, len(a)) self.assertTrue(ns.get('tns') + "Person" in a) self.assertTrue(ns.get('tns') + "Address" in a) self.assertTrue(ns.get('tns') + "AddressArray" in a)
def test_float(self): f = 1.22255645 element = Float.to_xml(f) self.assertEquals(element.text, '1.22255645') self.assertEquals('xs:float', element.get(ns.get('xsi') + 'type')) f2 = Float.from_xml(element) self.assertEquals(f2, f)
def test_integer(self): i = 12 integer = Integer() element = Integer.to_xml(i) self.assertEquals(element.text, '12') self.assertEquals('xs:int', element.get(ns.get('xsi') + 'type')) value = integer.from_xml(element) self.assertEquals(value, i)
def test_large_integer(self): i = 128375873458473 integer = Integer() element = Integer.to_xml(i) self.assertEquals(element.text, '128375873458473') self.assertEquals('xs:integer', element.get(ns.get('xsi') + 'type')) value = integer.from_xml(element) self.assertEquals(value, i)
def test_null(self): element = Null.to_xml('doesnt matter') self.assertEquals('1', element.get(ns.get('xs') + 'null')) value = Null.from_xml(element) self.assertEquals(None, value)
def test_null(self): element = Null.to_xml('doesnt matter') self.assertEquals('1', element.get(ns.get('xs') + 'nil')) value = Null.from_xml(element) self.assertEquals(None, value)