{% extends "base.html" %} {% block title %}Testing Framework{% endblock %} {% block breadcrumb %}Testing Framework{% endblock %} {% block extra_head %} {% endblock %} {% block content %} {# ═══════════════════════════════════════════════════════════════════ AQUILIA ADMIN — TESTING FRAMEWORK (v2 — Enhanced) Phase 31f: Comprehensive testing analytics dashboard ═══════════════════════════════════════════════════════════════════ #}

Testing Framework

Aquilia Testing v{{ framework_version }} — batteries-included testing integrated with every subsystem

{# ═══ STATUS BAR ═══ #}
{% if available %}
Available {% else %}
Not Loaded {% endif %}
· {{ summary.total_test_files }} test files · {{ summary.total_test_functions }} test functions · {{ summary.total_test_classes }} test classes · {{ "{:,}".format(summary.total_lines) }} lines · {{ "{:,}".format(total_assert_stmts) }} assert stmts · {{ total_async_tests }} async / {{ total_sync_tests }} sync
{# ═══ METRIC CARDS (row 1) ═══ #}
0
Test Functions
{{ summary.total_test_classes }} classes
0
Assertions
Custom assertion helpers
0
Fixtures
Pytest fixtures
0
Mock Systems
Faults, effects, cache, DI…
0
Test Files
{{ "{:,}".format(summary.total_lines) }} LOC
0
Components
{{ total_components }} subsystems covered
{# ═══ METRIC CARDS (row 2 — enhanced analytics) ═══ #}
0
Assert Statements
In test source files
0
Avg Tests / File
Test density metric
0
Avg LOC / Test
Code-per-test ratio
0
Avg Density
Tests per 100 LOC
0
Async Tests
{{ total_sync_tests }} synchronous
0
Categories
{% for k, v in category_breakdown.items() %}{{ k|title }}:{{ v }} {% endfor %}
{# ═══ CHARTS ROW 1: Distribution + Categories Doughnut + Coverage Radar ═══ #}
{# -- Test distribution by file -- #}

Tests per File

{# -- Test categories doughnut -- #}

Test Categories

{# -- Component coverage radar -- #}

Component Coverage

{# ═══ CHARTS ROW 2: Async/Sync + Assertions Doughnut + Test Density ═══ #}
{# -- Async vs Sync pie -- #}

Async vs Sync Tests

{# -- Assertion categories doughnut -- #}

Assertion Categories

{# -- Test density bar -- #}

Test Density (tests/100 LOC)

{# ═══ CHARTS ROW 3: Mock Infra + LOC + Imports Usage + Assertions Per File ═══ #}
{# -- Mock infrastructure bar -- #}

Mock Infrastructure

{# -- Lines of code horizontal bar -- #}

Lines of Test Code

{# -- Imports usage horizontal bar -- #}

Testing Imports Usage

{# -- Assertions per file -- #}

Assert Statements per File

{# ═══ TEST CASE CLASSES ═══ #}

Test Case Classes

{% for tc in test_classes %}
{{ tc.name }}
extends {{ tc.base }}
{{ tc.description }}
{% for feat in tc.features %} {{ feat }} {% endfor %}
{{ tc.category }}
{% endfor %}
{# ═══ HTTP & WEBSOCKET CLIENTS ═══ #} {% if client %}

Test Clients

{% if client.http %}
{{ client.http.name|default('TestClient') }}
In-process ASGI client — no network sockets
{% if client.http.methods is defined %}
HTTP Methods:
{% for m in client.http.methods %} {{ m }} {% endfor %}
{% endif %} {% if client.http.features is defined %}
{% for feat in client.http.features %} {{ feat }} {% endfor %}
{% endif %}
{% endif %} {% if client.websocket %}
{{ client.websocket.name|default('WebSocketTestClient') }}
In-process WebSocket testing client
{% if client.websocket.features is defined %}
{% for feat in client.websocket.features %} {{ feat }} {% endfor %}
{% endif %}
{% endif %}
{% endif %} {# ═══ MOCK INFRASTRUCTURE ═══ #} {% if mock_infra|length > 0 %}

Mock Infrastructure ({{ total_mocks }} systems)

{% for mock in mock_infra %} {% endfor %}
Name Module Description Features
{{ mock.name }} {{ mock.module }} {{ mock.description }}
{% for feat in mock.features %} {{ feat }} {% endfor %}
{% endif %} {# ═══ ASSERTION HELPERS ═══ #} {% if assertions|length > 0 %}

Assertion Helpers ({{ total_assertions }} methods)

{% for group in assertions %}
{{ group.category }} {{ group.count }}
{% for method in group.methods %} {{ method }} {% endfor %}
{% endfor %}
{% endif %} {# ═══ FIXTURES ═══ #} {% if fixtures|length > 0 %}

Pytest Fixtures ({{ total_fixtures }})

{% for fix in fixtures %}
{{ fix.name }} {% if fix.async %} async {% endif %}
{% endfor %}
{% endif %} {# ═══ UTILITY FUNCTIONS ═══ #} {% if utilities is defined and utilities|length > 0 %}

Utility Functions ({{ total_utilities }})

{% for util in utilities %}
{{ util.name }}
{{ util.description }}
{% endfor %}
{% endif %} {# ═══ COMPONENT COVERAGE TABLE ═══ #} {% if component_coverage is defined and component_coverage|length > 0 %}

Subsystem Coverage ({{ covered_components }}/{{ total_components }})

{% for comp in component_coverage %}
{% if comp.status == 'covered' %} {% else %} {% endif %}
{{ comp.name }}
{{ comp.module }}
{% endfor %}
{% endif %} {# ═══ TEST FILES TABLE (enhanced with search, category, density, asserts) ═══ #} {% if test_files|length > 0 %}

Discovered Test Files ({{ total_test_files }})

{% for f in test_files %} {% endfor %}
File Category Dir Lines Tests Asserts Density Async Sync
{{ f.name }} {{ f.category|default('other') }} {{ f.directory }} {{ "{:,}".format(f.lines) }} {{ f.test_count }} {{ f.assert_count|default(0) }} {{ "%.1f"|format(f.density|default(0)) }}
{{ f.async_tests|default(0) }} {{ f.sync_tests|default(0) }}
Total {{ "{:,}".format(summary.total_lines) }} {{ summary.total_test_functions }} {{ "{:,}".format(total_assert_stmts) }} {{ "%.1f"|format(avg_density) }} {{ total_async_tests }} {{ total_sync_tests }}
{% endif %} {# ═══ QUICK SETUP — CODE SNIPPETS ═══ #}

Quick Setup — Code Snippets

Copy-paste examples for Aquilia's testing utilities.

test_user_service.py
from aquilia.testing import AquiliaTestCase

class TestUserService(AquiliaTestCase):
    """Unit test for user service logic."""

    async def test_create_user(self):
        result = await self.app.di.get("user_service").create(
            name="Alice", email="alice@example.com"
        )
        self.assert_status(result, 201)
        self.assert_json_has(result, "id", "name")

    async def test_user_validation(self):
        with self.assertRaises(ValidationError):
            await self.app.di.get("user_service").create(name="")
test_auth_flow.py
from aquilia.testing import AquiliaTestCase

class TestAuthFlow(AquiliaTestCase):
    """Integration test across auth + sessions + DI."""

    async def test_login_creates_session(self):
        resp = await self.client.post("/auth/login", json={
            "username": "admin", "password": "secret"
        })
        self.assert_status(resp, 200)
        self.assert_json_has(resp, "token")
        # Verify session was created
        sessions = self.app.di.get("session_store")
        self.assertTrue(len(sessions.active()) > 0)
test_api_endpoints.py
from aquilia.testing import TestClient

async def test_api_endpoints():
    """Use TestClient for HTTP testing without network."""
    async with TestClient(app) as client:
        # GET request
        resp = await client.get("/api/users")
        assert resp.status == 200

        # POST with JSON body
        resp = await client.post("/api/users", json={
            "name": "Bob", "role": "editor"
        })
        assert resp.status == 201

        # Custom headers
        resp = await client.get("/api/profile", headers={
            "Authorization": "Bearer test-token"
        })
test_with_mocks.py
from aquilia.testing import AquiliaTestCase
from aquilia.testing import MockFaultEngine, MockEffectBus

class TestWithMocks(AquiliaTestCase):
    """Use mock infrastructure for isolated testing."""

    async def test_fault_handling(self):
        faults = MockFaultEngine()
        faults.inject("db_timeout", probability=1.0)

        with self.mock_subsystem("faults", faults):
            resp = await self.client.get("/api/data")
            self.assert_status(resp, 503)

    async def test_effect_bus(self):
        bus = MockEffectBus()
        await bus.emit("user.created", {"id": 1})
        bus.assert_emitted("user.created", count=1)
conftest.py
import pytest
from aquilia.testing import create_test_app, seed_database

@pytest.fixture
async def app():
    """Create a fresh test application instance."""
    app = await create_test_app(config={
        "database": {"url": "sqlite://:memory:"},
        "auth": {"secret": "test-secret"},
    })
    yield app
    await app.shutdown()

@pytest.fixture
async def seeded_app(app):
    """App with seed data for integration tests."""
    await seed_database(app, fixtures=["users", "posts"])
    return app
{# ═══ IMPORTS USAGE HEATMAP (text-based) ═══ #} {% if imports_usage %}

Testing Imports Heatmap

How many test files import each Aquilia testing utility.

{% for name, count in imports_usage.items() %}
{{ name }} {{ count }} files
{% endfor %}
{% endif %} {# ═══ CHART.JS INITIALIZATION ═══ #} {% endblock %}