(self)
| 383 | self.assertTrue(self.col_schema.is_valid(result)) |
| 384 | |
| 385 | def test_validation(self): |
| 386 | with self.assertRaises(ValueError) as ec: |
| 387 | DataElement(self.col_xml_root).validate() |
| 388 | self.assertIn("has no schema bindings", str(ec.exception)) |
| 389 | |
| 390 | col_data = self.col_schema.decode(self.col_xml_filename) |
| 391 | |
| 392 | self.assertIsNone(col_data.validate()) |
| 393 | self.assertTrue(col_data.is_valid()) |
| 394 | self.assertListEqual(list(col_data.iter_errors()), []) |
| 395 | |
| 396 | col_data = self.col_schema.decode(self.col_xml_root) |
| 397 | self.assertEqual(col_data.nsmap, {}) |
| 398 | self.assertTrue(col_data.is_valid()) |
| 399 | |
| 400 | # FIXME: are namespaces really needed for validation of data elements??? |
| 401 | # (that use iter_encode() instead of iter_decode() ...) |
| 402 | self.assertTrue(col_data.is_valid(namespaces={ |
| 403 | 'col': 'http://example.com/ns/collection', |
| 404 | 'xsi': 'http://www.w3.org/2001/XMLSchema-instance' |
| 405 | })) |
| 406 | |
| 407 | # Encoding back using the default namespace is simple with |
| 408 | # data elements because you still have the original tags. |
| 409 | self.assertTrue(col_data.is_valid(namespaces={ |
| 410 | '': 'http://example.com/ns/collection', |
| 411 | 'xsi': 'http://www.w3.org/2001/XMLSchema-instance' |
| 412 | })) |
| 413 | |
| 414 | def test_invalid_value_type(self): |
| 415 | col_data = self.col_schema.decode(self.col_xml_filename) |
nothing calls this directly
no test coverage detected