Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Beliagal/qa-report-automation/llms.txt

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

The Valoraclick QA Tool ships with a test suite in the tests/ directory built on pytest. The suite is intentionally focused on the two layers most critical to report correctness: the pure business-logic functions in logic.py and the PDF generation service in services.py. Both test modules are standard unittest.TestCase classes, which pytest discovers and runs automatically.

Test Structure

FileTypeWhat it covers
tests/test_logic.pyUnitvalidar_fecha() in logic.py — valid and invalid date strings
tests/test_integration.pyIntegrationPDFService.generate_report() — real PDF written to disk and verified

Running the Tests

1

Activate the virtual environment

Open a terminal in the project root and activate .venv so pytest and all dependencies are available:
.venv\Scripts\activate
2

Run the full test suite

Execute all discovered tests with a single command:
pytest
Alternatively, use the module invocation if pytest is not on your PATH:
python -m pytest
3

Run with verbose output

Pass the -v flag to see each individual test case listed with its pass/fail status:
pytest -v
Example output:
tests/test_logic.py::TestLogic::test_fechas_correctas  PASSED
tests/test_logic.py::TestLogic::test_fechas_incorrectas PASSED
tests/test_integration.py::TestIntegration::test_creacion_pdf_con_datos PASSED
4

Run a specific test file

Target a single module by passing its path to pytest:
pytest tests/test_logic.py
This is useful when iterating on logic changes without waiting for the (slightly slower) integration test to generate a PDF.

Unit Tests — test_logic.py

test_logic.py contains a TestLogic class that exercises validar_fecha() from logic.py. The function is expected to accept any properly formatted DD/MM/YYYY date and reject anything that does not match that pattern or represents an impossible calendar date.
tests/test_logic.py
import unittest
from logic import validar_fecha

class TestLogic(unittest.TestCase):
    def test_fechas_correctas(self):
        self.assertTrue(validar_fecha("30/04/2026"))
        self.assertTrue(validar_fecha("01/01/2024"))

    def test_fechas_incorrectas(self):
        self.assertFalse(validar_fecha("32/01/2024"))
        self.assertFalse(validar_fecha("ab/cd/efgh"))
        self.assertFalse(validar_fecha("2026-04-30"))
Test case breakdown:
InputExpectedReason
"30/04/2026"TrueValid date in DD/MM/YYYY format
"01/01/2024"TrueValid date in DD/MM/YYYY format
"32/01/2024"FalseDay 32 does not exist
"ab/cd/efgh"FalseNon-numeric characters fail the regex
"2026-04-30"FalseISO format (YYYY-MM-DD) is not accepted

Integration Tests — test_integration.py

test_integration.py contains a TestIntegration class that exercises PDFService.generate_report() end-to-end. It constructs a real ReportData object, populates it with one metadata entry and one test step, triggers the service, and then verifies that a non-empty PDF file was written to disk.
tests/test_integration.py
import unittest
import os
from models import ReportData
from services import PDFService

class TestIntegration(unittest.TestCase):
    def setUp(self):
        self.data = ReportData()
        self.service = PDFService()
        self.test_filename = "test_output_report.pdf"

    def test_creacion_pdf_con_datos(self):
        self.data.metadata["Tester:"] = "Sistema de Test"
        self.data.pruebas.append({
            "input": "Prueba de integración",
            "esp": "PDF generado",
            "obt": "PDF generado",
            "estado": "Pass",
            "img": ""
        })
        self.service.generate_report(self.data, self.test_filename)
        self.assertTrue(os.path.exists(self.test_filename))
        self.assertGreater(os.path.getsize(self.test_filename), 0)

    def tearDown(self):
        if os.path.exists(self.test_filename):
            os.remove(self.test_filename)
What the test verifies:
  1. setUp — fresh ReportData and PDFService instances are created before each test method.
  2. test_creacion_pdf_con_datos — a tester name and one Pass step are added to the data, then generate_report() is called with the output path test_output_report.pdf.
  3. Two assertions confirm the PDF exists on disk and has a non-zero file size, proving the fpdf2 rendering pipeline ran to completion.
  4. tearDown — the generated PDF is deleted after each test run to keep the working directory clean.

The integration test generates a real PDF file (test_output_report.pdf) in the current working directory — typically the project root when running pytest from there. tearDown deletes the file automatically after each run. Ensure the directory has write permissions before executing the test suite.
When contributing new tests, add them to the tests/ directory following the test_*.py naming convention so pytest discovers them automatically. Note that CSVService tests are not yet included in the suite — the service depends on pywin32 (a Windows-only package) to resolve Drive shortcuts. When writing tests for CSVService on non-Windows platforms, mock win32com.client.Dispatch with unittest.mock.patch to avoid import errors and isolate the CSV-writing logic from the Windows shell dependency.

Build docs developers (and LLMs) love