ETL Dinámico ships with four pytest test modules that together cover every layer of the pipeline — from live database connectivity to full end-to-end orchestration. Two of the four tests are completely database-free (pure unit tests with mocks), one verifies incremental-load filtering logic using patched I/O, and one confirms that both the OLTP and OLAP SQL Server connections are alive. Running the full suite takes only a few seconds and gives you immediate confidence that every component is working correctly.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/obedc295/proyect_dw/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before running the test suite, make sure the following are in place:Virtual Environment
Your project virtual environment must be activated so that all dependencies resolve from the correct location.
.env Configured
A valid
.env file with OLTP_* and OLAP_* connection variables must exist in the project root for connection tests to pass.pytest ≥ 9.1.1
pytest>=9.1.1 must be installed. It is listed in requirements.txt and is installed automatically in a fresh virtual environment.Running the Tests
Run all tests
Execute every test module in the This runs all four test functions across all four files in dependency-safe order.
tests/ directory with verbose output:Run a specific test file
Target a single module by passing its path directly:Replace
test_transformer.py with any other module name to isolate a different layer.Test Modules at a Glance
test_connection.py
test_conexiones() — Requires a live SQL Server connection. Creates a DatabaseClient instance and executes SELECT 1 against both the OLTP and OLAP engines, asserting that each returns 1.test_transformer.py
test_transformaciones_pandas() — Pure unit test; no database required. Exercises capitalize_transform (uppercase), concat_transform (column concatenation), and date_transform (year extraction) on a small in-memory DataFrame.test_loader.py
test_carga_incremental_filtra_correctamente() — Mocks the database client and patches pd.read_sql to simulate an existing DW row (CustomerID=10). Asserts that to_sql is called exactly once, confirming the incremental load path was executed.test_pipelines.py
test_flujo_completo_con_datos_reales() — Mocks the extractor and loader, then drives a full ETLPipeline.run_dynamic_etl() call with three territory rows and an upper column mapping. Verifies status, rows_extracted, and that the New_Name column contains correctly uppercased values.Connection Test Warning
test_connection.py requires a real, running SQL Server instance. If your .env file is missing, contains incorrect credentials, or your SQL Server is unreachable, test_conexiones will fail with an assertion error. The remaining three tests are entirely mock-based and will pass regardless of database availability.Running Without a Database
Expected Output
When all four tests pass, pytest prints a report similar to the following:PASSED line confirms that the corresponding layer of the ETL stack is behaving correctly. If any line shows FAILED or ERROR, check the traceback printed below the summary — the most common cause is a misconfigured .env (connection tests) or a breaking change in a service class (unit tests).