|
9 | 9 | from tests.integration.src.sqlbuild.compiler.compile.native_model_config._test_types import ( |
10 | 10 | ModelConfigBuildParityTestCase, |
11 | 11 | ModelValidationParityTestCase, |
| 12 | + NativeRejectionParityTestCase, |
12 | 13 | ) |
13 | 14 | from tests.integration.src.sqlbuild.compiler.compile.native_model_config.helpers import ( |
14 | 15 | BUILD_ENVIRONMENT, |
|
18 | 19 | generated_validation_requests, |
19 | 20 | model_config_build_parity, |
20 | 21 | model_validation_parity, |
| 22 | + validation_outcomes, |
21 | 23 | ) |
22 | 24 |
|
23 | 25 |
|
@@ -90,5 +92,87 @@ def test_given_generated_layers_when_building_config_then_native_matches_python_ |
90 | 92 | ) == ([], True, True, True), (parity.built, parity.deferred, parity.python_raised) |
91 | 93 |
|
92 | 94 |
|
| 95 | +@pytest.mark.parametrize( |
| 96 | + "test_case", |
| 97 | + [ |
| 98 | + NativeRejectionParityTestCase( |
| 99 | + description="a start bound shifted before year 1 in UTC", |
| 100 | + values={ |
| 101 | + "materialized": "incremental", |
| 102 | + "incremental_strategy": "append", |
| 103 | + "cursor": "updated_at", |
| 104 | + "cursor_type": "timestamp", |
| 105 | + "cursor_grain": "day", |
| 106 | + "cursor_start": "0001-01-01T00:00:00+01:00", |
| 107 | + "cursor_end": "2024-01-01", |
| 108 | + }, |
| 109 | + expected_native_accepted=False, |
| 110 | + expected_python_error=( |
| 111 | + "CompileInputError: model 'orders_daily': cursor_start value " |
| 112 | + "'0001-01-01T00:00:00+01:00' falls outside years 1-9999 once converted to UTC" |
| 113 | + ), |
| 114 | + ), |
| 115 | + NativeRejectionParityTestCase( |
| 116 | + description="an end bound shifted past year 9999 in UTC", |
| 117 | + values={ |
| 118 | + "materialized": "incremental", |
| 119 | + "incremental_strategy": "append", |
| 120 | + "cursor": "updated_at", |
| 121 | + "cursor_type": "timestamp", |
| 122 | + "cursor_grain": "day", |
| 123 | + "cursor_start": "2024-01-01", |
| 124 | + "cursor_end": "9999-12-31T23:59:00-01:00", |
| 125 | + }, |
| 126 | + expected_native_accepted=False, |
| 127 | + expected_python_error=( |
| 128 | + "CompileInputError: model 'orders_daily': cursor_end value " |
| 129 | + "'9999-12-31T23:59:00-01:00' falls outside years 1-9999 once converted to UTC" |
| 130 | + ), |
| 131 | + ), |
| 132 | + NativeRejectionParityTestCase( |
| 133 | + description="an unreadable unique key under an enforced contract", |
| 134 | + values={ |
| 135 | + "materialized": "incremental", |
| 136 | + "incremental_strategy": "merge", |
| 137 | + "unique_key": ["\udcff"], |
| 138 | + "contract": "enforced", |
| 139 | + "columns": {"order_id": None}, |
| 140 | + }, |
| 141 | + expected_native_accepted=False, |
| 142 | + expected_python_error=( |
| 143 | + "CompileInputError: model 'orders_daily': unique_key references column " |
| 144 | + "'\udcff' not declared in enforced contract" |
| 145 | + ), |
| 146 | + ), |
| 147 | + NativeRejectionParityTestCase( |
| 148 | + description="an unreadable snapshot check column under an enforced contract", |
| 149 | + values={ |
| 150 | + "materialized": "snapshot", |
| 151 | + "unique_key": "order_id", |
| 152 | + "snapshot_strategy": "check", |
| 153 | + "check_columns": ["\udcff"], |
| 154 | + "contract": "enforced", |
| 155 | + "columns": {"order_id": None}, |
| 156 | + }, |
| 157 | + expected_native_accepted=False, |
| 158 | + expected_python_error=( |
| 159 | + "CompileInputError: model 'orders_daily': check_columns references column " |
| 160 | + "'\udcff' not declared in enforced contract" |
| 161 | + ), |
| 162 | + ), |
| 163 | + ], |
| 164 | + ids=lambda case: case.description, |
| 165 | +) |
| 166 | +def test_given_python_rejected_edge_configs_when_validating_then_native_defers_to_python( |
| 167 | + test_case: NativeRejectionParityTestCase, |
| 168 | +) -> None: |
| 169 | + accepted, python_error = validation_outcomes(values=test_case.values) |
| 170 | + |
| 171 | + assert (accepted, python_error) == ( |
| 172 | + test_case.expected_native_accepted, |
| 173 | + test_case.expected_python_error, |
| 174 | + ) |
| 175 | + |
| 176 | + |
93 | 177 | if __name__ == "__main__": |
94 | 178 | pytest.main([__file__, "-vv"]) |
0 commit comments