|
6 | 6 | from pathlib import Path |
7 | 7 | import unittest |
8 | 8 | from unittest.mock import call, patch |
9 | | -from shutil import copyfile |
| 9 | +from shutil import copyfile, rmtree |
10 | 10 |
|
11 | 11 | import pandas as pd # noqa: TID253 |
12 | 12 | import pytest |
@@ -2323,6 +2323,65 @@ def test_test_output(tmp_path: Path) -> None: |
2323 | 2323 | assert "Ran 102 tests" in output |
2324 | 2324 | assert "FAILED (failures=51)" in output |
2325 | 2325 |
|
| 2326 | + # Case 4: Test that wide tables are split into even chunks for default verbosity |
| 2327 | + rmtree(tmp_path / "tests") |
| 2328 | + |
| 2329 | + wide_model_query = ( |
| 2330 | + "SELECT 1 AS col_1, 2 AS col_2, 3 AS col_3, 4 AS col_4, 5 AS col_5, 6 AS col_6, 7 AS col_7" |
| 2331 | + ) |
| 2332 | + |
| 2333 | + context.upsert_model( |
| 2334 | + _create_model( |
| 2335 | + meta="MODEL(name test.test_wide_model)", |
| 2336 | + query=wide_model_query, |
| 2337 | + default_catalog=context.default_catalog, |
| 2338 | + ) |
| 2339 | + ) |
| 2340 | + |
| 2341 | + tests_dir = tmp_path / "tests" |
| 2342 | + tests_dir.mkdir() |
| 2343 | + |
| 2344 | + wide_test_file = tmp_path / "tests" / "test_wide_model.yaml" |
| 2345 | + wide_test_file_content = """ |
| 2346 | + test_wide_model: |
| 2347 | + model: test.test_wide_model |
| 2348 | + outputs: |
| 2349 | + query: |
| 2350 | + rows: |
| 2351 | + - col_1: 6 |
| 2352 | + col_2: 5 |
| 2353 | + col_3: 4 |
| 2354 | + col_4: 3 |
| 2355 | + col_5: 2 |
| 2356 | + col_6: 1 |
| 2357 | + col_7: 0 |
| 2358 | + |
| 2359 | + """ |
| 2360 | + |
| 2361 | + wide_test_file.write_text(wide_test_file_content) |
| 2362 | + |
| 2363 | + with capture_output() as captured_output: |
| 2364 | + context.test() |
| 2365 | + |
| 2366 | + assert ( |
| 2367 | + """Data mismatch |
| 2368 | +┏━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓ |
| 2369 | +┃ ┃ col_1: ┃ col_1: ┃ col_2: ┃ col_2: ┃ col_3: ┃ col_3: ┃ col_4: ┃ col_4: ┃ |
| 2370 | +┃ Row ┃ Expec… ┃ Actual ┃ Expec… ┃ Actual ┃ Expec… ┃ Actual ┃ Expect… ┃ Actual ┃ |
| 2371 | +┡━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━┩ |
| 2372 | +│ 0 │ 6 │ 1 │ 5 │ 2 │ 4 │ 3 │ 3 │ 4 │ |
| 2373 | +└─────┴────────┴────────┴────────┴────────┴────────┴────────┴─────────┴────────┘ |
| 2374 | +
|
| 2375 | + Data mismatch |
| 2376 | +┏━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┓ |
| 2377 | +┃ ┃ col_5: ┃ col_5: ┃ col_6: ┃ col_6: ┃ col_7: ┃ col_7: ┃ |
| 2378 | +┃ Row ┃ Expected ┃ Actual ┃ Expected ┃ Actual ┃ Expected ┃ Actual ┃ |
| 2379 | +┡━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━┩ |
| 2380 | +│ 0 │ 2 │ 5 │ 1 │ 6 │ 0 │ 7 │ |
| 2381 | +└─────┴───────────┴───────────┴───────────┴───────────┴───────────┴────────────┘""" |
| 2382 | + in captured_output.stdout |
| 2383 | + ) |
| 2384 | + |
2326 | 2385 |
|
2327 | 2386 | @use_terminal_console |
2328 | 2387 | def test_test_output_with_invalid_model_name(tmp_path: Path) -> None: |
|
0 commit comments