Update test results directory structure and enhance Docker configurations

- Modified `.gitignore` to reflect the new path for test results.
- Updated `docker-compose.test.yml` to mount the correct test results directory.
- Adjusted `Dockerfile.test` to set the `PYTHONPATH` and ensure test results are saved in the updated location.
- Added `boto3` and `netron` to `requirements-test.txt` to support new functionalities.
- Updated `pytest.ini` to include the new `pythonpath` for test discovery.

These changes streamline the testing process and ensure compatibility with the updated directory structure.
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-28 00:13:08 +02:00
parent c20018745b
commit 243b69656b
48 changed files with 707 additions and 581 deletions
+12 -9
View File
@@ -1,7 +1,5 @@
import random
import shutil
import sys
import types
from pathlib import Path
from types import SimpleNamespace
@@ -11,13 +9,6 @@ import pytest
from tests.conftest import apply_constants_patch
if "matplotlib" not in sys.modules:
_mpl = types.ModuleType("matplotlib")
_plt = types.ModuleType("matplotlib.pyplot")
_mpl.pyplot = _plt
sys.modules["matplotlib"] = _mpl
sys.modules["matplotlib.pyplot"] = _plt
def _patch_augmentation_paths(monkeypatch, base: Path):
apply_constants_patch(monkeypatch, base)
@@ -44,6 +35,7 @@ def _seed():
def test_rt_aug_01_corrupted_image_skipped(
tmp_path, monkeypatch, fixture_images_dir, fixture_labels_dir
):
# Arrange
_patch_augmentation_paths(monkeypatch, tmp_path)
_augment_annotation_with_total(monkeypatch)
_seed()
@@ -59,13 +51,16 @@ def test_rt_aug_01_corrupted_image_skipped(
shutil.copy2(fixture_labels_dir / f"{stem}.txt", lbl_dir / f"{stem}.txt")
raw = (fixture_images_dir / f"{stem}.jpg").read_bytes()[:200]
(img_dir / "corrupted_trunc.jpg").write_bytes(raw)
# Act
Augmentator().augment_annotations()
# Assert
proc_img = Path(c.config.processed_images_dir)
assert len(list(proc_img.glob("*.jpg"))) == 8
@pytest.mark.resilience
def test_rt_aug_02_missing_label_no_crash(tmp_path, monkeypatch, fixture_images_dir):
# Arrange
_patch_augmentation_paths(monkeypatch, tmp_path)
_augment_annotation_with_total(monkeypatch)
import constants as c
@@ -79,7 +74,9 @@ def test_rt_aug_02_missing_label_no_crash(tmp_path, monkeypatch, fixture_images_
shutil.copy2(sorted(fixture_images_dir.glob("*.jpg"))[0], img_dir / f"{stem}.jpg")
aug = Augmentator()
aug.total_images_to_process = 1
# Act
aug.augment_annotation(SimpleNamespace(name=f"{stem}.jpg"))
# Assert
assert len(list(Path(c.config.processed_images_dir).glob("*.jpg"))) == 0
@@ -87,6 +84,7 @@ def test_rt_aug_02_missing_label_no_crash(tmp_path, monkeypatch, fixture_images_
def test_rt_aug_03_narrow_bbox_fewer_or_eight_variants(
tmp_path, monkeypatch, fixture_images_dir
):
# Arrange
_patch_augmentation_paths(monkeypatch, tmp_path)
_seed()
from augmentation import Augmentator
@@ -107,7 +105,9 @@ def test_rt_aug_03_narrow_bbox_fewer_or_eight_variants(
labels_path=str(proc_lbl),
labels=labels,
)
# Act
out = aug.augment_inner(img_ann)
# Assert
assert 1 <= len(out) <= 8
@@ -115,6 +115,7 @@ def test_rt_aug_03_narrow_bbox_fewer_or_eight_variants(
def test_rl_aug_01_augment_inner_exactly_eight_outputs(
tmp_path, monkeypatch, fixture_images_dir, fixture_labels_dir
):
# Arrange
_patch_augmentation_paths(monkeypatch, tmp_path)
_seed()
from augmentation import Augmentator
@@ -136,5 +137,7 @@ def test_rl_aug_01_augment_inner_exactly_eight_outputs(
labels_path=str(proc_lbl),
labels=labels,
)
# Act
out = aug.augment_inner(img_ann)
# Assert
assert len(out) == 8