mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 15:06:34 +00:00
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:
@@ -1,23 +1,10 @@
|
||||
import re
|
||||
import sys
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
from dto.annotationClass import AnnotationClass
|
||||
|
||||
|
||||
def _stub_train_imports():
|
||||
if getattr(_stub_train_imports, "_done", False):
|
||||
return
|
||||
for _name in ("ultralytics", "boto3", "netron", "requests"):
|
||||
if _name not in sys.modules:
|
||||
sys.modules[_name] = types.ModuleType(_name)
|
||||
sys.modules["ultralytics"].YOLO = type("YOLO", (), {})
|
||||
sys.modules["boto3"].client = lambda *a, **k: None
|
||||
_stub_train_imports._done = True
|
||||
|
||||
|
||||
def _name_lines_under_names(text):
|
||||
lines = text.splitlines()
|
||||
out = []
|
||||
@@ -39,7 +26,6 @@ _PLACEHOLDER_RE = re.compile(r"^-\s+Class-\d+\s*$")
|
||||
|
||||
@pytest.fixture
|
||||
def data_yaml_text(monkeypatch, tmp_path, fixture_classes_json):
|
||||
_stub_train_imports()
|
||||
import train
|
||||
|
||||
import constants as c
|
||||
@@ -52,14 +38,18 @@ def data_yaml_text(monkeypatch, tmp_path, fixture_classes_json):
|
||||
|
||||
|
||||
def test_bt_cls_01_base_classes(fixture_classes_json):
|
||||
# Act
|
||||
d = AnnotationClass.read_json()
|
||||
norm = {k: d[k] for k in range(17)}
|
||||
# Assert
|
||||
assert len(norm) == 17
|
||||
assert len({v.id for v in norm.values()}) == 17
|
||||
|
||||
|
||||
def test_bt_cls_02_weather_expansion(fixture_classes_json):
|
||||
# Act
|
||||
d = AnnotationClass.read_json()
|
||||
# Assert
|
||||
assert d[0].name == "ArmorVehicle"
|
||||
assert d[20].name == "ArmorVehicle(Wint)"
|
||||
assert d[40].name == "ArmorVehicle(Night)"
|
||||
@@ -67,11 +57,13 @@ def test_bt_cls_02_weather_expansion(fixture_classes_json):
|
||||
|
||||
@pytest.mark.resource_limit
|
||||
def test_bt_cls_03_yaml_generation(data_yaml_text):
|
||||
# Arrange
|
||||
text = data_yaml_text
|
||||
assert "nc: 80" in text
|
||||
# Act
|
||||
names = _name_lines_under_names(text)
|
||||
placeholders = [ln for ln in names if _PLACEHOLDER_RE.match(ln)]
|
||||
named = [ln for ln in names if not _PLACEHOLDER_RE.match(ln)]
|
||||
# Assert
|
||||
assert len(names) == 80
|
||||
assert len(placeholders) == 29
|
||||
assert len(named) == 51
|
||||
@@ -79,5 +71,7 @@ def test_bt_cls_03_yaml_generation(data_yaml_text):
|
||||
|
||||
@pytest.mark.resource_limit
|
||||
def test_rl_cls_01_total_class_count(data_yaml_text):
|
||||
# Act
|
||||
names = _name_lines_under_names(data_yaml_text)
|
||||
# Assert
|
||||
assert len(names) == 80
|
||||
|
||||
Reference in New Issue
Block a user