Skip to content

Commit 65b3687

Browse files
committed
feat: enhance test suite for ATT&CK to Excel export functionality
- Added slow marker to several tests in `test_cli.py` and `test_layers.py` to categorize them for longer execution times. - Refactored `test_export_excel` in `test_cli.py` to utilize a mock `ToExcel` class for testing Excel export argument wiring. - Improved `test_export_with_memstore_uses_current_dataframe_builder` and `test_export_with_pre_v18_version_uses_legacy_dataframe_builder` in `test_to_excel.py` to validate dataframe building logic based on version. - Introduced new tests in `test_to_excel.py` to verify the creation of expected workbooks, handling of empty data, deduplication of citations, and sanitization of matrix sheet names. - Updated `uv.lock` to require pytest version 9.0 or higher for development dependencies.
1 parent 089da48 commit 65b3687

13 files changed

Lines changed: 2020 additions & 2018 deletions

File tree

docs/CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ Run `just` with no arguments to see all available commands. Here are the most co
5151

5252
```bash
5353
just lint # Run pre-commit hooks (ruff format) on all files
54-
just test # Run tests
54+
just test # Run the full test suite, matching CI expectations
55+
just test-fast # Run the fast local subset, excluding integration and slow tests
5556
just test-cov # Run tests with coverage report
5657
just build # Build the package
5758
```
5859

60+
Use `just test-fast` while iterating locally on changes that do not need full STIX-backed export or other slow integration coverage. Tests or setup steps that normally take longer than 10 seconds should be marked `slow`, so they are skipped by `just test-fast`. Before opening a PR, run `just test`; GitHub Actions also runs the full suite with coverage.
61+
5962
To run STIX-backed tests against specific local bundles, pass the bundle paths to pytest:
6063

6164
```bash

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ ruff-format:
3535
test:
3636
uv run pytest
3737

38+
# Run the fast local test subset, excluding integration and slow tests
39+
test-fast:
40+
uv run pytest -m "not integration and not slow"
41+
3842
# Run tests with coverage
3943
test-cov:
4044
uv run pytest --cov=mitreattack

mitreattack/diffStix/changelog_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import textwrap
1111
from dataclasses import dataclass
1212
from pathlib import Path
13-
from typing import Dict, List, Optional
13+
from typing import Any, Dict, List, Optional
1414

1515
import markdown
1616
import requests
@@ -1429,7 +1429,7 @@ def get_changes_dict(self):
14291429
"""Return dict format summarizing detected differences."""
14301430
logger.info("Generating changes info")
14311431

1432-
changes_dict = {}
1432+
changes_dict: Dict[str, Any] = {}
14331433
for domain in self.domains:
14341434
changes_dict[domain] = {}
14351435

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dev = [
5555
"check-wheel-contents>=0.6.1",
5656
"commitizen>=4.9.1",
5757
"pre-commit>=4.0.0",
58-
"pytest>=8.4.2",
58+
"pytest>=9.0",
5959
"pytest-cov>=7.0.0",
6060
"pytest-dotenv>=0.5.2",
6161
"python-semantic-release>=10.5.0",
@@ -80,8 +80,13 @@ package = true
8080
module-name = "mitreattack"
8181
module-root = ""
8282

83-
[tool.pytest.ini_options]
83+
[tool.pytest]
84+
minversion = "9.0"
8485
testpaths = ["tests"]
86+
markers = [
87+
"integration: tests that exercise real external-size data or full integration paths",
88+
"slow: tests that are intentionally excluded from default fast runs",
89+
]
8590

8691
[tool.ruff]
8792
line-length = 120

0 commit comments

Comments
 (0)