Skip to content

Commit b60ff98

Browse files
committed
test: Add comprehensive test coverage improvements
- Add test_comprehensive_coverage.py with 46 new tests - Increase code coverage from 82% to 89% - Add tests/README.md documenting test organization - Cover previously untested functionality: - Channel discovery and management - Flake tools and statistics - Version history functionality - Utility tools (which, help, why, etc.) - Installation and package management - Discussion searches (Discourse, GitHub) - Edge cases and error handling - HTML parsing edge cases - Async helpers Current stats: 334 tests passing, 1560/1749 lines covered (89%)
1 parent 158195d commit b60ff98

File tree

2 files changed

+928
-0
lines changed

2 files changed

+928
-0
lines changed

tests/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# MCP-NixOS Test Suite
2+
3+
This directory contains comprehensive tests for the MCP-NixOS server, organized by functionality and purpose.
4+
5+
## Test Organization
6+
7+
### Core Functionality Tests
8+
- `test_server.py` - Main server module tests including helper functions, NixOS tools, Home Manager tools, and Darwin tools
9+
- `test_channels.py` - Channel discovery and management functionality
10+
- `test_options.py` - Configuration option search and display
11+
- `test_flakes.py` - Flake search and ecosystem functionality
12+
- `test_github_flakes.py` - GitHub flake search integration
13+
- `test_nixhub.py` - NixHub version history integration
14+
- `test_discussions.py` - Discourse and GitHub issue search
15+
16+
### Output and Formatting Tests
17+
- `test_plain_text_output.py` - Ensures all outputs are plain text (no XML/JSON leakage)
18+
- `test_edge_cases.py` - Edge case handling and error conditions
19+
20+
### Integration and Real-World Tests
21+
- `test_integration.py` - Integration tests with real APIs (marked with @pytest.mark.integration)
22+
- `test_real_world_scenarios.py` - Common user workflows and scenarios
23+
- `test_mcp_behavior.py` - MCP tool usage patterns and behavior evaluation
24+
- `test_context_awareness.py` - Context tracking and smart suggestions
25+
26+
### Specialized Tests
27+
- `test_agent_feedback_fixes.py` - Fixes based on agent feedback (darwin_search dock prioritization, hm_show enhancements)
28+
- `test_comprehensive_coverage.py` - Additional tests to improve code coverage to 90%+
29+
- `test_regression.py` - Regression tests for previously fixed bugs
30+
- `test_nixos_stats.py` - Statistics functionality tests
31+
- `test_evals.py` - AI usability evaluation tests
32+
- `test_mcp_tools.py` - MCP-specific tool tests
33+
34+
### Support Files
35+
- `conftest.py` - Pytest configuration and fixtures
36+
- `test_main.py` - Main entry point tests
37+
38+
## Running Tests
39+
40+
```bash
41+
# Run all tests
42+
pytest
43+
44+
# Run unit tests only
45+
pytest -k "not integration"
46+
47+
# Run with coverage
48+
pytest --cov=mcp_nixos --cov-report=html
49+
50+
# Run specific test file
51+
pytest tests/test_server.py
52+
53+
# Run with verbose output
54+
pytest -v
55+
```
56+
57+
## Test Markers
58+
59+
- `@pytest.mark.unit` - Unit tests that mock external dependencies
60+
- `@pytest.mark.integration` - Integration tests that make real API calls
61+
- `@pytest.mark.asyncio` - Async tests
62+
- `@pytest.mark.evals` - Evaluation tests for AI usability
63+
64+
## Coverage
65+
66+
The test suite aims for 90%+ code coverage. Current coverage can be checked with:
67+
68+
```bash
69+
pytest --cov=mcp_nixos --cov-report=term
70+
```

0 commit comments

Comments
 (0)