Open
Conversation
- Created `test_robotdashboard.py` to cover various functionalities of the RobotDashboard class, including initialization, output processing, and dashboard creation. - Implemented tests for handling outputs, including error scenarios for invalid XML and duplicate logs. - Added tests for the `print_runs`, `remove_outputs`, and `create_dashboard` methods to ensure correct behavior under different configurations. - Developed `test_server.py` to test the ApiServer class and its FastAPI endpoints, utilizing MagicMock for the RobotDashboard instance. - Covered authentication, output addition, log management, and error handling in the server tests. - Ensured comprehensive coverage of both successful and failure scenarios for all endpoints.
There was a problem hiding this comment.
Pull request overview
This PR introduces a comprehensive Python unit test suite (pytest + coverage) for the robotframework_dashboard package and integrates it into CI ahead of the existing Robot acceptance tests. It also includes a few small runtime/compatibility tweaks (notably SQLite datetime handling for Python 3.12+ and safer file reads in the FastAPI server).
Changes:
- Add extensive unit tests under
tests/(server endpoints, CLI/main orchestration, database, processors, dashboard generation, dependencies, arguments). - Add unit-test runner scripts + CI workflow job to run pytest with coverage and upload the report artifact.
- Make small production changes to improve resource handling/coverage annotations and SQLite datetime compatibility.
Reviewed changes
Copilot reviewed 22 out of 53 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_server.py |
New FastAPI ApiServer endpoint tests via TestClient + mocked RobotDashboard |
tests/test_robotdashboard.py |
New tests for RobotDashboard core workflow methods |
tests/test_processors.py |
New tests for OutputProcessor and legacy RF compatibility processors |
tests/test_main.py |
New tests for main() orchestration and server-start branch |
tests/test_dependencies.py |
New tests for dependency inlining/CDN blocks |
tests/test_database.py |
New tests for DatabaseProcessor CRUD, migration, and compat branches |
tests/test_dashboard.py |
New tests for dashboard generation and helpers |
tests/test_arguments.py |
New tests for CLI argument parsing/normalization and dotdict |
tests/conftest.py |
Shared fixtures for XML outputs, processors, and DB setup |
scripts/unittests.sh |
Linux/macOS unit test + coverage runner script |
scripts/unittests.bat |
Windows unit test + coverage runner script |
robotframework_dashboard/server.py |
Use context managers for file reads; adjust coverage pragmas |
robotframework_dashboard/main.py |
Mark __main__ guard as not coverable |
robotframework_dashboard/dependencies.py |
Mark an error branch as not coverable |
robotframework_dashboard/database.py |
Register SQLite adapter for datetime; clear connection on close |
robotframework_dashboard/abstractdb.py |
Add # pragma: no cover to abstract/optional methods |
requirements-dev.txt |
Add dev dependencies needed for unit tests and server tests |
pyproject.toml |
Add pytest warning filter configuration |
atest/testsuites/00_cli.robot |
Update acceptance-test output path to shared testdata/outputs |
atest/resources/keywords/general-keywords.resource |
Update CLI invocation paths to shared testdata/outputs |
.gitignore |
Ignore coverage file |
.github/workflows/tests.yml |
Add unit-tests job and gate robot tests on it |
.github/skills/unit-tests.md |
Document unit test layout, execution, and CI integration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+88
to
+93
| def test_get_admin_page_no_autoupdate_true_hides_refresh_card(): | ||
| server = _make_server(no_autoupdate=True) | ||
| html = server._get_admin_page() | ||
| # When no_autoupdate=True the placeholder is replaced with "" (visible) | ||
| assert "hidden" not in html or "placeholder_refresh_card_visibility" not in html | ||
|
|
Comment on lines
+446
to
+448
| def test_remove_outputs_all_empty_database(): | ||
| """When all=True and database is empty, remove_outputs should not be called.""" | ||
| server = _make_server() |
| #!/usr/bin/env bash | ||
| set -e | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| @@ -0,0 +1,3 @@ | |||
| set COVERAGE_FILE=results/.coverage | |||
| set PYTHONPATH=%~dp0.. | |||
| python -m pytest tests/ --cov=robotframework_dashboard --cov-report=term-missing --cov-report=html:results/coverage | |||
Comment on lines
+437
to
+439
| def test_get_data_null_run_alias_generates_auto_alias(db): | ||
| """get_data() assigns 'Alias 0' when run_alias is NULL (pre-0.6.0 compat).""" | ||
| db.open_database() |
Comment on lines
+323
to
+327
| def test_remove_by_run_start(populated_db): | ||
| populated_db.open_database() | ||
| data = populated_db.get_data() | ||
| run_start = data["runs"][0]["run_start"] | ||
| populated_db.remove_runs([f"run_start={run_start}"]) |
| admin_html = open(admin_file, "r").read() | ||
| with open(admin_file, "r", encoding="utf-8") as _f: | ||
| admin_html = _f.read() | ||
| admin_html = admin_html.replace('"placeholder_version"', __version__) |
Comment on lines
+9
to
+14
| import gzip | ||
| import io | ||
| import pytest | ||
| from pathlib import Path | ||
| from unittest.mock import MagicMock, patch, call | ||
| from fastapi.testclient import TestClient |
Comment on lines
+1
to
+3
| import shutil | ||
| import pytest | ||
| from datetime import datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_robotdashboard.pyto cover various functionalities of the RobotDashboard class, including initialization, output processing, and dashboard creation.print_runs,remove_outputs, andcreate_dashboardmethods to ensure correct behavior under different configurations.test_server.pyto test the ApiServer class and its FastAPI endpoints, utilizing MagicMock for the RobotDashboard instance.