This page documents all public classes, methods, and utility functions that make up the Valoraclick QA Tool. Developers extending or embedding the tool should reference this page. Each section maps directly to a source module: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.
gui.py, models.py, services.py, and logic.py.
TestingApp (gui.py)
TestingApp is the main application window. It extends ctk.CTk from the CustomTkinter library and owns the top-level lifecycle of a testing session — from UI construction and session persistence through to PDF export and Google Drive backup.
ReportData object (self.report_data), a PDFService (self.pdf_service), and a CSVService (self.csv_service). It sets self.session_file = "sesion_testing.json" and self.current_img = "". The window title is set to "QA Tool v1.0.0 Secure", the geometry is set to "1200x900", and the window is maximised by scheduling self.state('zoomed') via self.after(0, ...). A CTkScrollableFrame labelled "Panel de Control QA" is created as the main content area. Finally the constructor calls _setup_top_bar(), _setup_metadata_grid(), _setup_execution_form(), and _load_session() to build the complete UI and restore any in-progress session.
Key Methods
_on_export()
Triggers the full export pipeline: PDF generation followed by an automatic Google Drive CSV backup.
Internally, _on_export():
- Calls
_sync()to flush widget values intoreport_data.metadata. - Validates the
Fecha:field against^\d{2}/\d{2}/\d{4}$. If validation fails, a warning dialog is shown and the export is aborted. - Opens a Save As dialog restricted to
.pdffiles. - Calls
pdf_service.generate_report(report_data, path). - Calls
csv_service.export(report_data)for the automatic Drive backup. - Displays a success dialog reporting whether the Drive backup succeeded.
_on_add()
Appends a new test step to report_data.pruebas using the values currently in the step form.
The step dict constructed by _on_add() has the following shape:
_on_add() returns immediately without adding anything. After a successful append it calls _update_log(), _save_session(), and _clear_step().
_on_reset()
Displays a yes/no confirmation dialog. If confirmed:
- Calls
report_data.reset_data()to restore all metadata to defaults and emptypruebas. - Deletes
sesion_testing.jsonfrom disk if it exists. - Clears all metadata entry widgets and resets
Fecha:to today’s date. - Clears the Dependencias entry and the Resumen Ejecutivo textbox.
- Calls
_update_log()to refresh the log preview.
_save_session()
Persists the current session to disk so it can be recovered on the next launch.
_sync() first, then writes the following JSON structure to sesion_testing.json in the working directory:
_load_session()
Reads sesion_testing.json on application startup and restores the previous session into the UI.
_load_session() returns immediately. If it exists, it:
- Reads
pruebasback intoreport_data.pruebas. - Iterates over the
metadict and restores each value into the correspondingCTkEntrywidget. - Restores
depinto the Dependencias entry andresumeninto the Resumen Ejecutivo textbox. - Calls
_update_log()to populate the log preview.
The session file uses the key
"meta" (not "metadata") at the top level. This is intentional — see the Data Model page for the complete session JSON schema._sync()
Copies the current value of every UI widget into report_data.metadata.
self.entries (a dict mapping metadata keys to CTkEntry widgets) and writes each .get() value back to report_data.metadata. Also pulls dep from self.ent_dep and resumen from self.txt_resumen. This method must be called before any operation that reads report_data — most notably _on_export() and _save_session().
_on_img()
Opens a file picker dialog so the analyst can attach a screenshot to the current step.
*.png, *.jpg, and *.jpeg files. If the user selects a file, its absolute path is stored in self.current_img and the image button label changes to ✅ Imagen Ok. The path is consumed by _on_add() when the step is finalised.
Instance variable updated by
_on_img(). Holds the absolute path to the selected screenshot, or an empty string if no image has been chosen for the current step._clear_step()
Resets all step-form fields and the image selection after a step has been added.
self.current_img to an empty string and restores the image button text to "📸 Imagen" with its default colour (#3b8ed0). Called automatically by _on_add() after each successful step append.
_update_log()
Refreshes the CTkTextbox preview panel with a colour-coded summary of the current session.
CTkTextbox (self.log), clears it, and rewrites its contents using the underlying _textbox widget’s tag system for colour highlighting:
- Header lines (
--- VISTA PREVIA DEL INFORME ---and--- PASOS (n) ---) are rendered in blue (#3498db, bold). - Each step line is coloured green (
#2ecc71) for"Pass"steps or red (#e74c3c) for any other status. - Metadata key/value pairs from
self.entriesare printed in the default colour.
_validate_date_input(P)
Validator registered with the Fecha: entry widget via Tkinter’s validatecommand mechanism.
The proposed new value of the entry widget after the keypress. Provided automatically by the Tkinter validation framework.
True (allowing the keypress) only when:
len(P) <= 10, and- every character in
Pis a digit (0–9) or a forward slash (/).
ReportData (models.py)
ReportData is the central, plain-Python data container for a testing session. It carries no UI logic and no I/O; its sole responsibility is holding structured test data that other services can read and write.
reset_data()
Restores the object to a clean initial state. Called automatically by __init__() and again by TestingApp._on_reset() at the user’s request.
reset_data() completes:
self.metadatais set to:self.pruebasis set to an empty list[].
PDFService (services.py)
PDFService generates a formatted PDF report from a ReportData object using fpdf2.
generate_report(data, output_path)
Creates the PDF document in memory and writes it to output_path.
The generated document contains:
- A centred bold title — INFORME DE TESTING.
- A shaded INFORMACIÓN GENERAL section with a two-column grid of metadata fields: Aplicación, Tester, Fecha, Versión, and Resumen.
- A PASOS DE EJECUCIÓN table with columns: Acción / Entrada, Esperado, Obtenido, Estado. Pass rows are rendered in green text; Fail rows in red.
- For any step that has an attached image whose file still exists on disk, the image is embedded inline below its row at 100 mm width.
margin=15 bottom margin.
The test session data to render. The method reads
data.metadata for the header section and iterates data.pruebas for the execution table.Absolute or relative file path where the PDF will be written, including the
.pdf extension. The directory must already exist and be writable.CSVService (services.py)
CSVService exports the test session to a timestamped CSV backup file, targeting a Google Drive folder via a Windows shell shortcut.
__init__() and are not configurable at runtime without subclassing.
Hard-coded to
r"G:\Mi unidad\Informes.lnk". This is the Windows shell shortcut that _resolve_shortcut() attempts to resolve to find the actual Drive folder.Hard-coded to
r"G:\Mi unidad". Used as the export destination when the shortcut cannot be resolved.export(data)
Resolves the target directory, builds a unique filename, and writes the CSV.
The test session data to export. Both
data.metadata and data.pruebas are written to the CSV.True if the CSV was written successfully; False if an exception was raised.On success: the full absolute path to the written CSV file (e.g.
G:\Mi unidad\Informes\backup_2025-07-15_143022_Ana_García.csv). On failure: the string representation of the exception.backup_<YYYY-MM-DD_HHMMSS>_<Tester>.csv, where spaces in the tester name are replaced with underscores. The CSV is encoded as utf-8-sig (UTF-8 with BOM) for compatibility with Microsoft Excel.
The CSV structure is:
| Campo | Valor | |||
|---|---|---|---|---|
Aplicación: | Valoraclick | |||
Tester: | … | |||
| … | … | |||
| (blank row) | ||||
| Acción | Esperado | Obtenido | Estado | Ruta Imagen |
| … | … | … | … | … |
_resolve_shortcut(path)
Resolves a Windows .lnk shortcut file to its target directory path using win32com.
Absolute path to a
.lnk Windows shortcut file, e.g. r"G:\Mi unidad\Informes.lnk".The
TargetPath string from the shortcut if the file exists and can be parsed by WScript.Shell. Returns None if the file does not exist, if win32com raises any exception, or if the path is valid but the shortcut is broken.Utility Functions (logic.py)
These module-level functions contain business logic shared across the application. They have no side effects and no dependency on the GUI.
validar_fecha(fecha_str)
Validates that a string represents a calendar date in DD/MM/YYYY format.
The date string to validate, e.g.
"15/07/2025".True only when both of the following conditions hold:
- The string matches the regular expression
^\d{2}/\d{2}/\d{4}$. datetime.strptime(fecha_str, '%d/%m/%Y')does not raise aValueError— meaning the day and month values are calendar-valid (e.g."31/02/2025"would fail here).
False otherwise.
obtener_color_estado(estado)
Maps a test step status string to an RGB colour tuple for use in rendered output.
The status string. Expected values are
"Pass" or "Fail".(46, 204, 113) — a green shade — when estado == "Pass". (231, 76, 60) — a red shade — for any other value, including "Fail" and unexpected strings.