Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/elenacarino-max/Pildora4_ext_StarWars/llms.txt

Use this file to discover all available pages before exploring further.

MLflow Jedi ships with a unittest suite that validates the four pillars of the application’s correctness: the question bank content, mission definitions, AST-based code validation logic, and database operations. The tests are designed to run quickly, require no network access, and never touch the production data directory — making them safe to run at any time, including immediately before a classroom session.

Running the tests

From the app-v2/ directory with dependencies installed, run:
python -m unittest discover -s tests -v
Or, if running from the repository root:
cd app-v2
python -m unittest discover -s tests -v
The -v flag prints each test case name and result to the terminal. A fully passing run ends with OK; any failure or error prints a traceback identifying the broken component.

Test coverage

The suite is split across four files, each targeting a distinct layer of the application.

test_questions.py — question bank integrity

Validates the structure and completeness of the 50-question bank in core/questions.py.
  • Asserts that exactly 50 questions exist and all 50 have unique id values.
  • Verifies that every question’s solution field is accepted by the validate_question_answer validator — meaning no question in the bank has an invalid or unreachable correct answer.
  • Checks that a session selection (choose_session_question_ids) always returns exactly 6 questions, one per topic, covering the complete set of TOPICS (Experiment, Run, Parameters, Metrics, Artifacts, Model).

test_missions.py — mission content validation

Validates the static mission and holocron definitions in core/missions.py and core/holocrons.py.
  • Asserts that exactly 6 chambers, 3 missions, and 7 holocrons are defined.
  • Checks that the set of mission id values (tatooine, coruscant, mustafar) matches the keys in ORIENTATIVE_RESULTS — every mission has expected reference metrics.
  • Verifies that every holocron has a non-empty task, exactly 4 steps, and a non-empty deliverable field.

test_code_validator.py — AST-based code validation

Tests the safe, execution-free code analysis performed by core/code_validator.py. Student submissions are never executed; the validator inspects the abstract syntax tree instead.
  • Accepts correct code: a valid mlflow.set_experiment(...) call passes the experiment chamber.
  • Rejects wrong function category: using mlflow.log_param in a metrics chamber returns valid=False with a message containing "métrica".
  • Rejects unauthorised calls: a open(...) call in a parameters chamber is rejected with a message containing "autorizada".
  • Enforces mission submission structure: a submission that logs only one artifact (instead of the required two) fails with a message containing "dos artefactos".
The validator is the security boundary between student input and the application. These tests ensure it enforces all expected constraints without false positives on correct answers.

test_database.py — database operations

Tests the full lifecycle of a session using a temporary SQLite database patched over GAME_DB, so production data is never affected.
  • Session and team progression: creates a session, joins a team ("Guardianes de Naboo"), verifies initial chamber_index is 0, completes chamber 0, and confirms chamber_index advances to 1 and score equals 20.
  • Defense validation: attempts to save a defense where selected_run and discarded_run are the same value and asserts a ValueError is raised — the app prevents teams from comparing a run against itself.
  • Question persistence and penalty: verifies that a session is created with exactly 6 question IDs and that those IDs are consistently returned by get_session. After 5 consecutive failed attempts, force_advance_chamber advances the team but applies a penalty of −10 points.

Prerequisites

All test dependencies are provided by the standard requirements.txt:
streamlit==1.49.1
streamlit-ace==0.1.1
mlflow==3.3.2
scikit-learn==1.7.1
pandas==2.3.2
matplotlib==3.10.6
python-dotenv==1.1.1
Install them before running the suite:
python -m pip install -r requirements.txt
Tests run against an in-memory or temporary directory database patched via unittest.mock.patch. They do not read from or write to the production data/ directory. You can run the suite while the application is running without any risk to live session data.
Run the tests before every deployment update, as recommended in the maintenance guide (app-v2/docs/GUIA_MANTENIMIENTO.md). A clean test run confirms that question content, mission definitions, and validation logic are all internally consistent in the version you are about to deploy.

Build docs developers (and LLMs) love