|
| 1 | +""" |
| 2 | +Pytest suite for MATLAB Z-file reader functionality. |
| 3 | +
|
| 4 | +Tests reading and parsing MATLAB Z-files for different case IDs. |
| 5 | +""" |
| 6 | + |
| 7 | +import pytest |
| 8 | + |
| 9 | +from aurora.sandbox.io_helpers.garys_matlab_zfiles.matlab_z_file_reader import ( |
| 10 | + test_matlab_zfile_reader, |
| 11 | +) |
| 12 | + |
| 13 | + |
| 14 | +# ============================================================================= |
| 15 | +# Fixtures |
| 16 | +# ============================================================================= |
| 17 | + |
| 18 | + |
| 19 | +@pytest.fixture(params=["IAK34ss", "synthetic"]) |
| 20 | +def case_id(request): |
| 21 | + """ |
| 22 | + Provide case IDs for MATLAB Z-file reader tests. |
| 23 | +
|
| 24 | + Parameters: |
| 25 | + - IAK34ss: Real data case |
| 26 | + - synthetic: Synthetic data case |
| 27 | + """ |
| 28 | + return request.param |
| 29 | + |
| 30 | + |
| 31 | +@pytest.fixture |
| 32 | +def iak34ss_case_id(): |
| 33 | + """Fixture for IAK34ss case ID (real data).""" |
| 34 | + return "IAK34ss" |
| 35 | + |
| 36 | + |
| 37 | +@pytest.fixture |
| 38 | +def synthetic_case_id(): |
| 39 | + """Fixture for synthetic case ID.""" |
| 40 | + return "synthetic" |
| 41 | + |
| 42 | + |
| 43 | +# ============================================================================= |
| 44 | +# Tests |
| 45 | +# ============================================================================= |
| 46 | + |
| 47 | + |
| 48 | +def test_matlab_zfile_reader_iak34ss(iak34ss_case_id): |
| 49 | + """Test MATLAB Z-file reader with IAK34ss real data case.""" |
| 50 | + test_matlab_zfile_reader(case_id=iak34ss_case_id) |
| 51 | + |
| 52 | + |
| 53 | +@pytest.mark.skip(reason="Synthetic case currently disabled in original test") |
| 54 | +def test_matlab_zfile_reader_synthetic(synthetic_case_id): |
| 55 | + """Test MATLAB Z-file reader with synthetic data case.""" |
| 56 | + test_matlab_zfile_reader(case_id=synthetic_case_id) |
| 57 | + |
| 58 | + |
| 59 | +@pytest.mark.parametrize("test_case_id", ["IAK34ss"]) |
| 60 | +def test_matlab_zfile_reader_parametrized(test_case_id): |
| 61 | + """ |
| 62 | + Parametrized test for MATLAB Z-file reader. |
| 63 | +
|
| 64 | + This test runs for each case ID in the parametrize decorator. |
| 65 | + To enable synthetic test, add "synthetic" to the parametrize list. |
| 66 | + """ |
| 67 | + test_matlab_zfile_reader(case_id=test_case_id) |
| 68 | + |
| 69 | + |
| 70 | +class TestMatlabZFileReader: |
| 71 | + """Test class for MATLAB Z-file reader functionality.""" |
| 72 | + |
| 73 | + def test_iak34ss_case(self): |
| 74 | + """Test reading IAK34ss MATLAB Z-file.""" |
| 75 | + test_matlab_zfile_reader(case_id="IAK34ss") |
| 76 | + |
| 77 | + @pytest.mark.skip(reason="Synthetic case needs verification") |
| 78 | + def test_synthetic_case(self): |
| 79 | + """Test reading synthetic MATLAB Z-file.""" |
| 80 | + test_matlab_zfile_reader(case_id="synthetic") |
| 81 | + |
| 82 | + |
| 83 | +# ============================================================================= |
| 84 | +# Integration Tests |
| 85 | +# ============================================================================= |
| 86 | + |
| 87 | + |
| 88 | +class TestMatlabZFileReaderIntegration: |
| 89 | + """Integration tests for MATLAB Z-file reader.""" |
| 90 | + |
| 91 | + @pytest.mark.parametrize( |
| 92 | + "case_id,description", |
| 93 | + [ |
| 94 | + ("IAK34ss", "Real data from IAK34ss station"), |
| 95 | + # ("synthetic", "Synthetic test data"), # Uncomment to enable |
| 96 | + ], |
| 97 | + ids=["IAK34ss"], # Add "synthetic" when uncommenting above |
| 98 | + ) |
| 99 | + def test_reader_with_description(self, case_id, description): |
| 100 | + """ |
| 101 | + Test MATLAB Z-file reader with case descriptions. |
| 102 | +
|
| 103 | + Parameters |
| 104 | + ---------- |
| 105 | + case_id : str |
| 106 | + The case identifier for the MATLAB Z-file |
| 107 | + description : str |
| 108 | + Human-readable description of the test case |
| 109 | + """ |
| 110 | + # Log the test case being run |
| 111 | + print(f"\nTesting case: {case_id} - {description}") |
| 112 | + test_matlab_zfile_reader(case_id=case_id) |
| 113 | + |
| 114 | + |
| 115 | +# ============================================================================= |
| 116 | +# Backward Compatibility |
| 117 | +# ============================================================================= |
| 118 | + |
| 119 | + |
| 120 | +def test(): |
| 121 | + """ |
| 122 | + Legacy test function for backward compatibility. |
| 123 | +
|
| 124 | + This maintains the original test interface from test_matlab_zfile_reader.py |
| 125 | + """ |
| 126 | + test_matlab_zfile_reader(case_id="IAK34ss") |
| 127 | + |
| 128 | + |
| 129 | +if __name__ == "__main__": |
| 130 | + # Run pytest on this file |
| 131 | + pytest.main([__file__, "-v"]) |
0 commit comments