Ejemplo n.º 1
0
 def test_deserialize_using_file(self):
     sch = Schema(self.xsd_file)
     des = sch.deserialize(self.xml_file)
     self.assertIsInstance(des, dict)
     self.assertIn('wizard', des)
Ejemplo n.º 2
0
 def test_validate_with_invalid_XML_using_file(self):
     sch = Schema(self.xsd_file)
     validated = sch.validate(self.xml_file_invalid)
     self.assertFalse(validated)
Ejemplo n.º 3
0
 def test_get_validation_errors_using_file(self):
     sch = Schema(self.xsd_file)
     errors = sch.get_validation_errors(self.xml_string)
     self.assertEqual(errors, list())
Ejemplo n.º 4
0
 def test_get_validation_errors_invalid_XML_using_file(self):
     sch = Schema(self.xsd_file)
     errors = sch.get_validation_errors(self.xml_file_invalid)
     self.assertTrue(len(errors) > 0)
     self.assertItemsEqual([(u'SCHEMASV', 2, 0, u'ERROR', u'SCHEMAV_CVC_ELT_1',
         u"Element 'wizard': No matching global declaration available for the validation root.")], errors)
Ejemplo n.º 5
0
 def test_validate_with_invalid_XML(self):
     sch = Schema(self.xsd_string)
     validated = sch.validate(self.xml_string_invalid)
     self.assertFalse(validated)
Ejemplo n.º 6
0
 def test_validate_with_valid_XML(self):
     sch = Schema(self.xsd_string)
     validated = sch.validate(self.xml_string)
     self.assertTrue(validated)
Ejemplo n.º 7
0
 def test_validate_without_XSD(self):
     from porteira import CannotValidate
     sch = Schema()
     self.assertRaises(CannotValidate,
         lambda: sch.validate(self.xml_string))
Ejemplo n.º 8
0
 def test_serialize(self):
     sch = Schema()
     ser = sch.serialize(test_asserts.DICT_OBJ)
     self.assertEqual(ser,
         '<?xml version="1.0" encoding="utf-8"?>\n<a><c>2</c><b>1</b></a>')
Ejemplo n.º 9
0
 def test_deserialize_without_xsd(self):
     sch = Schema()
     des = sch.deserialize(self.xml_string)
     self.assertIsInstance(des, dict)
     self.assertIn('wizard', des)