testsAndMisc-archive/python_pkg/praca_magisterska_video/tests/test_gen_agent.py
Krzysztof kuhy Rudnicki 996617d4a0 test: achieve 100% branch coverage across all python_pkg packages
- Add comprehensive tests for all packages (3572 tests, 100% branch coverage)
- Split oversized test files to stay under 500-line limit
- Add per-file ruff ignores for test-appropriate suppressions
- Fix _cache_decks.py to properly convert JSON lists to tuples
- Add session-scoped conftest fixture for logging handler cleanup (Python 3.14)
- Update ruff pre-commit hook to v0.15.2
- Add codespell ignore words for test data
- Add generated output files to .gitignore
2026-03-21 17:51:36 +01:00

164 lines
5.0 KiB
Python

"""Tests for agent diagram modules (GROUP 1).
Covers:
- generate_agent_diagrams.py (helpers, dataclasses)
- _agent_reactive.py (draw_see_think_act, draw_3t_architecture)
- _agent_cognitive.py (draw_behavior_tree, draw_bdi_model)
"""
from __future__ import annotations
import matplotlib as mpl
mpl.use("Agg")
import matplotlib.pyplot as plt
import pytest
pytestmark = pytest.mark.usefixtures("_no_savefig")
_MOD = "python_pkg.praca_magisterska_video.generate_images"
# ── helpers in generate_agent_diagrams ──────────────────────────────────
class TestAgentHelpers:
"""Test draw_box, draw_arrow, draw_dashed_arrow and dataclasses."""
def test_draw_box_rounded(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
BoxStyle,
draw_box,
)
fig, ax = plt.subplots()
draw_box(ax, (0, 0), (1, 1), "hi", BoxStyle(rounded=True))
plt.close(fig)
def test_draw_box_not_rounded(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
BoxStyle,
draw_box,
)
fig, ax = plt.subplots()
draw_box(ax, (0, 0), (1, 1), "hi", BoxStyle(rounded=False))
plt.close(fig)
def test_draw_box_no_style(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
draw_box,
)
fig, ax = plt.subplots()
draw_box(ax, (0, 0), (1, 1), "hi")
plt.close(fig)
def test_draw_arrow_with_label(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
ArrowCfg,
draw_arrow,
)
fig, ax = plt.subplots()
draw_arrow(ax, (0, 0), (1, 1), ArrowCfg(label="lbl"))
plt.close(fig)
def test_draw_arrow_no_label(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
draw_arrow,
)
fig, ax = plt.subplots()
draw_arrow(ax, (0, 0), (1, 1))
plt.close(fig)
def test_draw_dashed_arrow_with_label(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
DashedArrowCfg,
draw_dashed_arrow,
)
fig, ax = plt.subplots()
draw_dashed_arrow(ax, (0, 0), (1, 1), DashedArrowCfg(label="lbl"))
plt.close(fig)
def test_draw_dashed_arrow_no_label(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
draw_dashed_arrow,
)
fig, ax = plt.subplots()
draw_dashed_arrow(ax, (0, 0), (1, 1))
plt.close(fig)
def test_dataclass_defaults(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
ArrowCfg,
BoxStyle,
DashedArrowCfg,
)
bs = BoxStyle()
assert bs.rounded is True
assert bs.fill == "white"
ac = ArrowCfg()
assert ac.label == ""
dc = DashedArrowCfg()
assert dc.label == ""
def test_module_constants(self) -> None:
from python_pkg.praca_magisterska_video.generate_images.generate_agent_diagrams import (
BG,
DPI,
GRAY5,
OUTPUT_DIR,
)
assert DPI == 300
assert BG == "white"
assert isinstance(GRAY5, str)
assert isinstance(OUTPUT_DIR, str)
# ── _agent_reactive ────────────────────────────────────────────────────
class TestAgentReactive:
"""Test draw_see_think_act and draw_3t_architecture."""
def test_draw_see_think_act(self) -> None:
from python_pkg.praca_magisterska_video.generate_images._agent_reactive import (
draw_see_think_act,
)
draw_see_think_act()
def test_draw_3t_architecture(self) -> None:
from python_pkg.praca_magisterska_video.generate_images._agent_reactive import (
draw_3t_architecture,
)
draw_3t_architecture()
# ── _agent_cognitive ───────────────────────────────────────────────────
class TestAgentCognitive:
"""Test draw_behavior_tree (covers all node types) and draw_bdi_model."""
def test_draw_behavior_tree(self) -> None:
from python_pkg.praca_magisterska_video.generate_images._agent_cognitive import (
draw_behavior_tree,
)
draw_behavior_tree()
def test_draw_bdi_model(self) -> None:
from python_pkg.praca_magisterska_video.generate_images._agent_cognitive import (
draw_bdi_model,
)
draw_bdi_model()