How to run tests (answers user question): Manual execution: ./run_tests.sh # Quick way with auto-configured python python -m pytest tests/unit/ -v # Direct pytest command Automated (Gitea Actions): - Tests run on every push/PR to main branch - Workflow file: .gitea/workflows/test.yml - Status visible at repo actions page CI skips PySide6-dependent GUI tests by default.
This commit is contained in:
1 parent
4887379896
commit
57add9e337
3 files changed
+94
-12
No files matched your search
@@ -0,0 +1,45 @@
|
||||
# Gitea Actions CI workflow - runs tests on every push/PR
|
||||
name: Test Suite
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.14'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt 2>/dev/null || true
|
||||
pip install pytest numpy psutil Pillow
|
||||
|
||||
- name: Run tests (skip GUI tests)
|
||||
run: |
|
||||
python -m pytest tests/unit/ \
|
||||
--ignore=tests/unit/test_updater.py \
|
||||
--ignore=tests/unit/test_plugin_manager.py \
|
||||
--ignore=tests/unit/test_flares.py \
|
||||
-v --tb=short
|
||||
|
||||
- name: Test summary
|
||||
if: always()
|
||||
run: |
|
||||
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
|
||||
python -m pytest tests/unit/ \
|
||||
--ignore=tests/unit/test_updater.py \
|
||||
--ignore=tests/unit/test_plugin_manager.py \
|
||||
--ignore=tests/unit/test_flares.py \
|
||||
--co -q 2>/dev/null | grep "test session" >> $GITHUB_STEP_SUMMARY || true
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Run pytest tests with proper Python path
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Use full python path if in Hermes environment
|
||||
if [ -f "/opt/hermes/tools/python-3.14.9+202****1021-linux-x64/bin/python" ]; then
|
||||
PYTHON="/opt/hermes/tools/python-3.14.9+202****1021-linux-x64/bin/python"
|
||||
else
|
||||
PYTHON="python3"
|
||||
fi
|
||||
|
||||
echo "Running tests with: $PYTHON"
|
||||
|
||||
# Run all tests except GUI-dependent ones (requires PySide6)
|
||||
$PYTHON -m pytest tests/unit/ \
|
||||
--ignore=tests/unit/test_updater.py \
|
||||
--ignore=tests/unit/test_plugin_manager.py \
|
||||
--ignore=tests/unit/test_flares.py \
|
||||
"$@"
|
||||
+29
-12
@@ -16,24 +16,41 @@ tests/
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
# Install development dependencies
|
||||
pip install -r requirements-dev.txt
|
||||
# Quick way: use the test runner script
|
||||
./run_tests.sh
|
||||
|
||||
# Run all unit tests
|
||||
pytest tests/unit/ -v
|
||||
# Install dependencies (if needed)
|
||||
pip install pytest numpy psutil Pillow
|
||||
|
||||
# Run all non-GUI unit tests
|
||||
python -m pytest tests/unit/ \
|
||||
--ignore=tests/unit/test_updater.py \
|
||||
--ignore=tests/unit/test_plugin_manager.py \
|
||||
--ignore=tests/unit/test_flares.py \
|
||||
-v
|
||||
|
||||
# Run specific test file
|
||||
pytest tests/unit/test_updater.py -v
|
||||
|
||||
# Run with coverage
|
||||
pytest --cov=src tests/ -v
|
||||
pytest tests/unit/test_security_utils.py -v
|
||||
```
|
||||
|
||||
## Test Coverage Goals
|
||||
**Note**: `test_updater.py`, `test_plugin_manager.py`, and `test_flares.py` require PySide6 (GUI framework) and are skipped by default.
|
||||
|
||||
## Test Coverage Status
|
||||
|
||||
Current test suite:
|
||||
- **security_utils.py**: 30 tests ✅ (all passing)
|
||||
- **auth_utils.py**: 12 tests ✅ (all passing)
|
||||
- **logging_config.py**: 15 tests ✅ (all passing)
|
||||
- **Total**: 57 passing tests
|
||||
|
||||
See `tests/unit/` for all test files.
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
Tests automatically run on every push via Gitea Actions:
|
||||
- Workflow: `.gitea/workflows/test.yml`
|
||||
- Status: https://git.research.dezeeuw.ca/hermes/flares/actions
|
||||
|
||||
- `updater.py`: 100% (security-critical)
|
||||
- Core modules: >80%
|
||||
- Overall project: >60% (initial target)
|
||||
|
||||
## Writing Tests
|
||||
|
||||
|
||||
Reference in new issue
Block a user