|
4 | 4 | from collections import namedtuple |
5 | 5 | import datetime |
6 | 6 | import io |
| 7 | +import logging |
7 | 8 | import pytest |
8 | 9 | pytest.importorskip("lxml") |
9 | 10 | from lxml import etree |
|
14 | 15 | from conftest import (getConfig, gettestdata, icat_version, |
15 | 16 | get_icatdata_schema, testdatadir) |
16 | 17 |
|
| 18 | +logger = logging.getLogger(__name__) |
17 | 19 |
|
18 | 20 | def get_test_investigation(client): |
19 | 21 | query = Query(client, "Investigation", conditions={ |
@@ -355,7 +357,7 @@ def test_ingest_schema(client, investigation, schemadir, case): |
355 | 357 | reader = IngestReader(client, case.metadata, investigation) |
356 | 358 | with get_icatdata_schema().open("rb") as f: |
357 | 359 | schema = etree.XMLSchema(etree.parse(f)) |
358 | | - assert schema.validate(reader.infile) |
| 360 | + schema.assertValid(reader.infile) |
359 | 361 |
|
360 | 362 | @pytest.mark.parametrize("case", [ |
361 | 363 | pytest.param(c, id=c.metadata.name, marks=c.marks) for c in cases |
@@ -560,9 +562,10 @@ def test_ingest_error_invalid(client, investigation, schemadir, case): |
560 | 562 | datasets = [] |
561 | 563 | for name in case.data: |
562 | 564 | datasets.append(client.new("Dataset", name=name)) |
563 | | - with pytest.raises(icat.InvalidIngestFileError): |
| 565 | + with pytest.raises(icat.InvalidIngestFileError) as exc: |
564 | 566 | reader = IngestReader(client, case.metadata, investigation) |
565 | 567 | reader.ingest(datasets, dry_run=True, update_ds=True) |
| 568 | + logger.info("Raised %s: %s", exc.type.__name__, exc.value) |
566 | 569 |
|
567 | 570 | searcherr_attr_metadata = NamedBytesIO("""<?xml version='1.0' encoding='UTF-8'?> |
568 | 571 | <icatingest version="1.0"> |
@@ -621,9 +624,10 @@ def test_ingest_error_searcherr(client, investigation, schemadir, case): |
621 | 624 | datasets = [] |
622 | 625 | for name in case.data: |
623 | 626 | datasets.append(client.new("Dataset", name=name)) |
624 | | - with pytest.raises(icat.SearchResultError): |
| 627 | + with pytest.raises(icat.SearchResultError) as exc: |
625 | 628 | reader = IngestReader(client, case.metadata, investigation) |
626 | 629 | reader.ingest(datasets, dry_run=True, update_ds=True) |
| 630 | + logger.info("Raised %s: %s", exc.type.__name__, exc.value) |
627 | 631 |
|
628 | 632 |
|
629 | 633 | customcases = [ |
@@ -731,7 +735,7 @@ def test_ingest_env(monkeypatch, client, investigation, schemadir, case): |
731 | 735 | reader = IngestReader(client, case.metadata, investigation) |
732 | 736 | with get_icatdata_schema().open("rb") as f: |
733 | 737 | schema = etree.XMLSchema(etree.parse(f)) |
734 | | - assert schema.validate(reader.infile) |
| 738 | + schema.assertValid(reader.infile) |
735 | 739 | version_elem = reader.infile.xpath("/icatdata/head/apiversion") |
736 | 740 | assert version_elem |
737 | 741 | assert version_elem[0].text == str(client.apiversion) |
0 commit comments