diff --git a/testdata/empty.e57 b/testdata/empty.e57 new file mode 100644 index 0000000..e69de29 diff --git a/testdata/invalid.e57 b/testdata/invalid.e57 new file mode 100644 index 0000000..1538b8e --- /dev/null +++ b/testdata/invalid.e57 @@ -0,0 +1 @@ +Invalid data \ No newline at end of file diff --git a/testdata/justxml.e57 b/testdata/justxml.e57 new file mode 100644 index 0000000..7ea8459 --- /dev/null +++ b/testdata/justxml.e57 @@ -0,0 +1,40 @@ + + + + 1 + + + + + 9.8737110645898819e+008 + + + + + + + + + -9.4688999999999995e-002 + 6.1008999999999994e-002 + 4.0010999999999998e-002 + 1.8732099999999999e-001 + -6.1872999999999997e-002 + 5.8798999999999997e-002 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test_e57.py b/tests/test_e57.py index 18ebef0..e1ba4ff 100644 --- a/tests/test_e57.py +++ b/tests/test_e57.py @@ -33,3 +33,89 @@ def test_global_box_center(): assert X == pytest.approx(-0.016840) assert Y == pytest.approx(0.113666) assert Z == pytest.approx(-0.001537) + + +def test_file_not_found(): + raised = False + try: + e57.read_points(r"testdata/filenotfound.e57") + except RuntimeError as e: + raised = True + assert "Failed to read E57" in str(e) + assert "Unable to open file" in str(e) + assert raised + + +def test_empty_file(): + raised = False + try: + e57.read_points(r"testdata/empty.e57") + except RuntimeError as e: + raised = True + assert "Failed to read E57" in str(e) + assert "Failed to read E57 file header" in str(e) + assert raised + + +def test_invalid_file(): + raised = False + try: + e57.read_points(r"testdata/invalid.e57") + except RuntimeError as e: + raised = True + assert "Failed to read E57" in str(e) + assert "Failed to read E57 file header" in str(e) + assert raised + + +def test_just_xml(): + raised = False + try: + e57.read_points(r"testdata/justxml.e57") + except RuntimeError as e: + raised = True + assert "Invalid E57 content" in str(e) + assert "Found unsupported signature in header" in str(e) + assert raised + + +def test_raw_xml_file_not_found(): + raised = False + try: + e57.raw_xml(r"testdata/filenotfound.e57") + except FileNotFoundError: + raised = True + assert raised + + +def test_raw_xml_empty(): + raised = False + try: + e57.raw_xml(r"testdata/empty.e57") + except RuntimeError as e: + raised = True + assert "Failed to read E57" in str(e) + assert "Cannot read page size bytes" in str(e) + assert raised + + +def test_raw_xml_invalid(): + raised = False + try: + e57.raw_xml(r"testdata/invalid.e57") + except RuntimeError as e: + raised = True + assert "Failed to read E57" in str(e) + assert "Cannot read page size bytes" in str(e) + assert raised + + +def test_raw_xml_just_xml(): + raised = False + try: + e57.raw_xml(r"testdata/justxml.e57") + except RuntimeError as e: + raised = True + assert "Failed to read E57" in str(e) + assert "Failed creating paged CRC reader" in str(e) + assert raised