AI Hub should be tested as both a reusable Django app and an operational admin product.
The goal is not only "the code runs." The goal is:
Users can configure providers, models, agents, knowledge, tools, pipelines and GAME sessions without breaking the host project.
Run Django checks:
python manage.py check
Run AI Hub tests:
python manage.py test ai_hub
Run AI Hub plus the host integration app:
python manage.py test your_host_app ai_hub
Run the full project suite:
python manage.py test
If the project uses a virtual environment, run these commands through it (for example .venv/bin/python manage.py test ai_hub on Unix, or the equivalent interpreter path on Windows).
AI Hub needs coverage at several layers.
| Layer | What it proves |
|---|---|
| Models | Configuration rules are enforced. |
| Services | Runtime behavior is predictable. |
| Contracts | Bad payloads fail clearly. |
| Admin views | Non-technical users can operate the app. |
| Integration adapters | Host projects can use AI Hub safely. |
| Regression tests | Known failures do not return. |
Test provider and model rules:
Test agent rules:
Test pipeline rules:
Contracts are one of the strongest defenses against confusing AI failures.
Test:
Django 5.2 LTS and current-Django migration/system-check compatibility,
Missing required keys.
Example failing payload:
{
"summary": "This is missing the required final_output key."
}
Expected result:
The step fails with a clear contract validation error.
Test successful execution:
Test failure behavior:
on_error = stop stops the session.on_error = continue records the error and continues safely.on_error = fallback uses the fallback agent.Test admin behavior:
Test successful execution:
Test stop behavior:
Example GAME response:
{
"action": "finish",
"message": "The goal is complete.",
"complete": true,
"final_answer": "Final result."
}
Test admin behavior:
Do not hit real providers in unit tests.
Mock the model call service and return predictable data.
Test:
Recommended pattern:
Arrange session configuration.
Mock model response.
Run service.
Assert session status, final context and step telemetry.
AI Hub admin is part of the product, not just a debugging surface.
Test these pages:
/admin/ai_hub//admin/ai_hub/workspaces/orchestrator//admin/ai_hub/workspaces/game//admin/ai_hub/pipelinedefinition/control-center/Test expectations:
Manual responsive checks should include:
Check:
Every host project should test its adapter.
Example flow:
Host object -> create ExecutionSession -> run AI Hub -> persist host result -> update host UI status.
Test:
Keep tests for bugs that have already happened.
Recommended regression cases:
DEBUG=False.After deployment:
/admin/ai_hub/.Each GAME subsystem has an env-var kill switch. Test that:
create_goal raises when AI_HUB_GAME_GOALS_ENABLED=False.claim_next_goal raises when AI_HUB_GAME_SCHEDULER_ENABLED=False.execute_game_action raises when AI_HUB_GAME_ACTION_DISPATCH_ENABLED=False.record_memory raises when AI_HUB_GAME_MEMORY_ENABLED=False.resume_goal_execution raises when AI_HUB_GAME_RESUME_ENABLED=False.run_delegated_agent raises when AI_HUB_GAME_DELEGATION_ENABLED=False.Use @override_settings(FLAG_NAME=False) in tests. The reusable app fallback is fail-closed. _core enables GAME by default only in DEBUG development; production requires explicit environment opt-in for each flag.
Feature tests cover whole boundaries rather than only one public function: goal-bound session creation/execution, memory read and write, action dispatch/approval, scheduler claims, resume and delegated child policy.
Before enabling a GAME phase in a non-development environment, confirm all of these:
Migrations apply cleanly against the target database.
Focused phase tests are green.
Full ai_hub suite is green (python manage.py test ai_hub).
Admin screens load for a staff user.
Legacy GAME sessions continue to execute.
A manual vertical-slice test succeeds (create workspace → goal → session → finish).
Logs show no unhandled exceptions during the smoke test.
Rollback path is confirmed: the feature flag can be set to False without a deploy.
Delegated policy and budget concurrency are validated on PostgreSQL.
Admin mutation-bypass and payload-redaction regressions are green.
Run:
python manage.py check
python manage.py test ai_hub
python manage.py test
If the full suite is slow, at minimum run:
python manage.py check
python manage.py test ai_hub your_host_app
Ask me anything — agents, pipelines, GAME loops, setup or configuration.
Enter to send · Shift+Enter for new line · Ctrl+/ to toggle · Full history →