Description
The repository currently has no unit tests. Adding a test infrastructure would improve code quality, enable safe refactoring, and support CI/CD workflows.
Current State
- No
tests/ directory
- No test fixtures or mocking infrastructure
- Classes are tightly coupled to HuggingFace API (hard to test offline)
Proposed Solution
1. Add pytest infrastructure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_generator.py # Generator unit tests
├── test_extractor.py # Enhanced extractor tests
├── test_scoring.py # Completeness scoring tests
├── test_api.py # API endpoint tests
└── fixtures/
├── sample_model_card.json
└── expected_aibom.json
2. Create mock HuggingFace API responses
# conftest.py
@pytest.fixture
def mock_hf_api(mocker):
mock = mocker.patch('huggingface_hub.HfApi')
mock.return_value.model_info.return_value = MockModelInfo(...)
return mock
3. Add CycloneDX schema validation
def test_aibom_schema_compliance():
aibom = generator.generate_aibom("test/model")
validate(aibom, cyclonedx_1_6_schema) # JSON Schema validation
Benefits
- Catch regressions before deployment
- Enable offline development/testing
- Support for CI/CD integration
- Easier onboarding for new contributors
- Validate CycloneDX 1.6 compliance automatically
Dependencies to Add
pytest>=7.0.0
pytest-mock>=3.10.0
pytest-cov>=4.0.0
jsonschema>=4.17.0
Volunteer
Happy to help set up the initial test infrastructure and create example tests for core functionality.
Description
The repository currently has no unit tests. Adding a test infrastructure would improve code quality, enable safe refactoring, and support CI/CD workflows.
Current State
tests/directoryProposed Solution
1. Add pytest infrastructure
2. Create mock HuggingFace API responses
3. Add CycloneDX schema validation
Benefits
Dependencies to Add
Volunteer
Happy to help set up the initial test infrastructure and create example tests for core functionality.