Files
ai-training/tests/test_infrastructure.py
T
Oleksandr Bezdieniezhnykh 222f552a10 [AZ-171] Add TensorRT tests, AC coverage gate in implement skill, optimize test infrastructure
- Add TensorRT export tests with graceful skip when no GPU available
- Add AC test coverage verification step (Step 8) to implement skill
- Add test coverage gap analysis to new-task skill
- Move exported_models fixture to conftest.py as session-scoped (shared across modules)
- Reorder tests: e2e training runs first so images/labels are available for all tests
- Consolidate teardown into single session-level cleanup in conftest.py
- Fix infrastructure tests to count files dynamically instead of hardcoded 20

Made-with: Cursor
2026-03-28 21:32:28 +02:00

62 lines
1.8 KiB
Python

import constants as c
def test_fixture_images_dir_has_jpegs(fixture_images_dir):
jpgs = list(fixture_images_dir.glob("*.jpg"))
assert len(jpgs) > 0
def test_fixture_labels_dir_has_yolo_labels(fixture_labels_dir, fixture_images_dir):
txts = list(fixture_labels_dir.glob("*.txt"))
jpgs = list(fixture_images_dir.glob("*.jpg"))
assert len(txts) > 0
assert len(txts) == len(jpgs)
def test_fixture_onnx_model_bytes(fixture_onnx_model):
assert len(fixture_onnx_model) > 0
def test_fixture_classes_json_exists(fixture_classes_json):
assert fixture_classes_json.is_file()
assert fixture_classes_json.name == "classes.json"
def test_work_dir_layout(work_dir):
assert (work_dir / "images").is_dir()
assert (work_dir / "labels").is_dir()
def test_sample_image_label_paths(sample_image_label):
img, lbl = sample_image_label
assert img.suffix.lower() == ".jpg"
assert lbl.suffix == ".txt"
assert img.exists() and lbl.exists()
assert img.stem == lbl.stem
def test_sample_images_labels_factory(sample_images_labels):
img_dir, lbl_dir = sample_images_labels(3)
assert len(list(img_dir.glob("*.jpg"))) == 3
assert len(list(lbl_dir.glob("*.txt"))) == 3
def test_corrupted_label_content(corrupted_label):
text = corrupted_label.read_text(encoding="utf-8")
assert "1.5" in text
def test_edge_bbox_label_exists(edge_bbox_label):
assert edge_bbox_label.read_text(encoding="utf-8").strip()
def test_empty_label_file(empty_label):
assert empty_label.read_text(encoding="utf-8") == ""
def test_constants_patch_uses_tmp(constants_patch, tmp_path):
constants_patch(tmp_path)
assert c.config.root.startswith(str(tmp_path))
assert c.config.data_dir.startswith(str(tmp_path))
assert c.config.current_onnx_model.startswith(str(tmp_path))