Skip to content

Commit c544c29

Browse files
author
Your Name
committed
Issue_1001
1 parent af5e774 commit c544c29

File tree

6 files changed

+256
-4
lines changed

6 files changed

+256
-4
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[run]
2+
source = .
3+
include = */*.py
4+
5+
[report]
6+
show_missing = True

docs/Tests/testing_plan.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Testing Plan for Project
2+
3+
## Overview
4+
This document outlines the current testing status and identifies priority areas where additional testing is necessary to ensure application robustness and maintainability.
5+
6+
## Note on Test Coverage
7+
The percentages of test coverage reported below are derived using the `coverage` tool. This tool generates a coverage report as part of the Run Full Test Suite, which triggers every time a commit is made to a branch for which there is an open PR. Observations from these reports can be viewed directly in the terminal.
8+
9+
## Current Testing Status Overview
10+
11+
### Well-Covered Areas (90-100% Coverage)
12+
- **Configuration and Initial Setup**
13+
- `config/__init__.py`, `config/celery_app.py`, `config/settings/base.py`, `config/settings/__init__.py`, `config/settings/test.py`: These configurations are crucial for the application's initial setup and runtime environment, and they are well-tested ensuring stability in configuration loading and processing.
14+
15+
- **Environmental Justice Features**
16+
- All modules within `environmental_justice` except some migrations showing high test coverage. This includes models, views, and serializers which are critical to the functionality of the environmental justice features.
17+
18+
- **Feedback System**
19+
- Similar to environmental justice, the feedback system shows robust testing across its serializers, views, and most models.
20+
21+
### Areas with Moderate Coverage (70-89% Coverage)
22+
- **sde_collections**
23+
- Some modules in `sde_collections` like `admin.py`, `models/collection.py`, and `models/candidate_url.py` show moderate coverage, suggesting that critical business logic related to collection management could benefit from additional testing.
24+
25+
### Critical Areas with Insufficient Tests (<70% Coverage)
26+
- **Settings Files**
27+
- `config/settings/local.py` and `config/settings/production.py`: These files are crucial as they define environment-specific settings but currently have 0% coverage. Immediate attention is required to ensure that all configurations hold up under various environments.
28+
29+
- **Configuration Generation**
30+
- Most of the `config_generation` scripts such as `db_to_xml.py`, `api.py`, `generate_commands.py`, etc., are critically under-tested. Given that these scripts likely play a significant role in setting up and maintaining the application state, comprehensive tests are essential.
31+
32+
- **Utilities and Helpers**
33+
- Utility scripts and helpers like those in `sde_collections/utils`, particularly `github_helper.py` and `health_check.py`, show significant gaps in testing. These are important for the application's integration and maintenance operations.
34+
35+
## Recommendations for Immediate Test Development
36+
37+
### High Priority Tests
38+
1. **Complete Testing for Settings Management**
39+
- Develop tests for `config/settings/local.py` and `config/settings/production.py` to validate all configurations under simulated environments to prevent deployment issues.
40+
41+
2. **Robust Tests for Configuration Generation**
42+
- Implement unit and integration tests for the `config_generation` module to ensure all configurations and settings are generated correctly and errors are handled gracefully.
43+
44+
3. **Enhanced Testing for Collection Management**
45+
- Focus on increasing coverage for `sde_collections/models` and `sde_collections/views`. Given their direct impact on user data management and interface behavior, it is critical to cover these with more comprehensive tests including edge cases and failure modes.
46+
47+
### Medium Priority Tests
48+
1. **Utility Scripts and Helpers**
49+
- Scripts that support operational tasks such as `sde_collections/utils/github_helper.py` and `health_check.py` need thorough testing to ensure reliability in operational tasks.
50+
51+
2. **Admin Interfaces and Forms**
52+
- Given the moderate coverage in some admin and form-related areas, additional tests should be considered to cover all user interactions and data validation scenarios.
53+
54+
### Lower Priority Tests
55+
1. **Further Testing of Well-Covered Areas**
56+
- While not immediate, ensure that any new features or changes in areas like `environmental_justice` and `feedback` modules continue to maintain high coverage and reflect any new business logic or changes.
57+
58+
## Testing Plan Execution
59+
60+
- **Schedule and Assignments**: Assign test development tasks according to priority, with scheduled milestones for high-priority tests within the next sprint. Medium and lower priority tests can be scheduled for subsequent sprints.
61+
- **Resources**: Allocate resources not only for writing tests but also for setting up better test environments and potentially integrating more comprehensive CI/CD pipelines to automate and validate coverage on each build.
62+
- **Review and Adapt**: Continuously monitor test coverage metrics and adapt the testing plan as the project evolves. This dynamic approach will help ensure that the testing strategy remains aligned with project goals and technological shifts.

docs/Tests/testing_plan_2.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Testing Plan
2+
3+
## Overview
4+
This document provides a comprehensive outline of our application's current test coverage, identifies areas that require immediate testing attention, and guides future test development priorities.
5+
6+
## Note on Test Coverage
7+
The percentages of test coverage reported below are derived using the `coverage` tool. This tool generates a coverage report as part of the Run Ful Test Suite, which triggers every time a commit is made to a branch for which there is an open PR. Observations from these reports can be viewed directly in the terminal.
8+
9+
## Testing Categories and Current Coverage
10+
11+
### Configuration and Setup
12+
- **Files and Coverage**:
13+
- `config/settings/local.py` (0%)
14+
- `config/settings/production.py` (0%)
15+
- `config/settings/base.py` (100%)
16+
- `config/urls.py` (71%)
17+
- `config/wsgi.py` (0%)
18+
19+
### Model Layer
20+
- **Files and Coverage**:
21+
- `environmental_justice/models.py` (97%)
22+
- `feedback/models.py` (64%)
23+
- `sde_collections/models/candidate_url.py` (82%)
24+
- `sde_collections/models/collection.py` (65%)
25+
- `sde_collections/models/collection_choice_fields.py` (86%)
26+
- `sde_collections/models/delta_patterns.py` (89%)
27+
- `sde_collections/models/delta_url.py` (77%)
28+
- `sde_collections/models/pattern.py` (46%)
29+
- `sde_indexing_helper/users/models.py` (100%)
30+
31+
### Views and Controllers
32+
- **Files and Coverage**:
33+
- `environmental_justice/views.py` (100%)
34+
- `feedback/views.py` (100%)
35+
- `sde_collections/views.py` (38%)
36+
37+
### Data Serialization and APIs
38+
- **Files and Coverage**:
39+
- `environmental_justice/serializers.py` (100%)
40+
- `feedback/serializers.py` (100%)
41+
- `sde_collections/serializers.py` (75%)
42+
43+
### Admin Interface
44+
- **Files and Coverage**:
45+
- `environmental_justice/admin.py` (100%)
46+
- `feedback/admin.py` (100%)
47+
- `sde_collections/admin.py` (66%)
48+
49+
### Utilities and Helpers
50+
- **Files and Coverage**:
51+
- `sde_collections/utils/*.py` (Various coverage)
52+
- `sde_indexing_helper/utils/*.py` (0% to 100% coverage)
53+
54+
### Testing Infrastructure
55+
- **Files and Coverage**:
56+
- `sde_collections/tests/*.py` (High coverage with some gaps)
57+
- `sde_indexing_helper/users/tests/*.py` (High coverage with minor gaps)
58+
59+
### Database and Migration Scripts
60+
- **Files and Coverage**:
61+
- `config_generation/*.py` (Mostly 0% with some critical scripts untested)
62+
- All migration files across modules (Varied coverage, some with 0%)
63+
64+
### Task Automation and Background Jobs
65+
- **Files and Coverage**:
66+
- `sde_collections/tasks.py` (44%)
67+
68+
### Critical Areas for Immediate Testing
69+
- **Configuration Files**: Immediate attention to `local.py` and `production.py` is crucial for environment-specific settings.
70+
- **View Layers in `sde_collections`**: Given their centrality to application logic and low coverage.
71+
- **Model Complexity**: Specifically, the `sde_collections/models/collection.py` and `pattern.py` due to their low coverage and complexity.
72+
73+
## Recommended Actions
74+
1. **Expand Unit Tests**: Focus on untested configuration files and complex models.
75+
2. **Integration Tests**: Develop tests for views to ensure full application flow is covered.
76+
3. **Continuous Integration Improvements**: Ensure that all tests are executed during CI processes, and add checks for test coverage thresholds.
77+
78+
## Conclusion
79+
Prioritizing these areas will ensure robustness and reliability of our application, addressing both immediate testing gaps and setting a foundation for continuous quality assurance.

docs/Tests/testing_plan_3.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Testing Plan
2+
3+
## Overview
4+
This document provides a comprehensive outline of our application's current test coverage, identifies areas that require immediate testing attention, and guides future test development priorities.
5+
6+
## Note on Test Coverage
7+
The percentages of test coverage reported below are derived using the `coverage` tool. This tool generates a coverage report as part of the Run Full Test Suite, which triggers every time a commit is made to a branch for which there is an open PR. Observations from these reports can be viewed directly in the terminal.
8+
9+
## Testing Categories and Current Coverage
10+
11+
### Configuration and Setup
12+
- **Critical and Untested**:
13+
- `config/settings/local.py` (0%): Environment-specific settings for local development.
14+
- `config/settings/production.py` (0%): Environment-specific settings for production environments.
15+
- `config/wsgi.py` (0%): WSGI configuration for deployment.
16+
- **Partially Tested**:
17+
- `config/urls.py` (71%): URL dispatching and routing configurations.
18+
- **Tested**:
19+
- `config/settings/base.py` (100%): Base settings including middleware, database configurations, etc.
20+
21+
### Model Layer
22+
- **Critical and Undertested**:
23+
- `sde_collections/models/collection.py` (65%): Core model for handling collections, requires deeper testing due to its critical role in data management.
24+
- `sde_collections/models/pattern.py` (46%): Handles complex pattern matching logic, significantly under-tested.
25+
- `feedback/models.py` (64%): Involves important logic for managing feedback, requires additional coverage to ensure robust data integrity and operations.
26+
- **Tested**:
27+
- `environmental_justice/models.py` (97%)
28+
- `sde_collections/models/candidate_url.py` (82%)
29+
- `sde_collections/models/collection_choice_fields.py` (86%)
30+
- `sde_collections/models/delta_patterns.py` (89%)
31+
- `sde_collections/models/delta_url.py` (77%)
32+
- `sde_indexing_helper/users/models.py` (100%)
33+
34+
### Views and Controllers
35+
- **Critical and Undertested**:
36+
- `sde_collections/views.py` (38%): Central component for application's user interface logic, critically under-tested.
37+
- **Tested**:
38+
- `environmental_justice/views.py` (100%)
39+
- `feedback/views.py` (100%)
40+
41+
### Data Serialization and APIs
42+
- **Critical and Undertested**:
43+
- `sde_collections/serializers.py` (75%): Essential for API interaction, requires further testing to ensure robust data serialization.
44+
- **Tested**:
45+
- `environmental_justice/serializers.py` (100%)
46+
- `feedback/serializers.py` (100%)
47+
48+
### Admin Interface
49+
- **Critical and Undertested**:
50+
- `sde_collections/admin.py` (66%): Admin interface for managing application data, requires additional tests.
51+
- **Tested**:
52+
- `environmental_justice/admin.py` (100%)
53+
- `feedback/admin.py` (100%)
54+
55+
### Utilities and Helpers
56+
- **Critical and Undertested/Untested**:
57+
- `sde_collections/utils/github_helper.py` (19%)
58+
- `sde_collections/utils/health_check.py` (14%)
59+
- `sde_collections/utils/bulk_github_push.py` (0%)
60+
- `sde_collections/utils/generate_deployment_message.py` (0%)
61+
- `sde_collections/utils/slack_utils.py` (79%)
62+
- `sde_indexing_helper/utils/storages.py` (0%)
63+
64+
### Testing Infrastructure
65+
- **Tested with Gaps**:
66+
- `sde_collections/tests/*.py`
67+
- `sde_indexing_helper/users/tests/*.py`
68+
69+
### Database and Migration Scripts
70+
- **Critical and Mostly Untested**:
71+
- `config_generation/*.py`: Most scripts involved in database configuration and migration scripts are critically under-tested, posing a risk to data integrity and application setup.
72+
73+
### Task Automation and Background Jobs
74+
- **Critical and Undertested**:
75+
- `sde_collections/tasks.py` (44%): Handles background tasks and automation, significantly under-tested considering their operational importance.
76+
77+
## Critical Areas for Immediate Testing
78+
1. **Configuration Files**: Immediate testing for `config/settings/local.py` and `config/settings/production.py` to ensure they function correctly across different environments.
79+
2. **Core Business Logic in Models and Views**: Focus on significantly under-tested `sde_collections/models/collection.py` and `sde_collections/views.py`.
80+
3. **Utility Scripts and Background Jobs**: Address the lack of tests for critical utilities such as `sde_collections/utils/github_helper.py` and `sde_collections/tasks.py`.
81+
82+
## Recommended Actions
83+
- **Expand Unit Tests**: For critical configuration files and complex models.
84+
- **Integration Tests**: Enhance coverage for views and serializers to ensure complete application workflows.
85+
- **Continuous Integration Improvements**: Implement tests during CI processes and enforce coverage thresholds.
86+
87+
## Conclusion
88+
This plan highlights critical testing needs and outlines a structured approach to addressing immediate testing gaps while setting a long-term foundation for continuous quality assurance. By following this plan, we aim to improve the robustness and reliability of our application systematically.

init.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
echo "Running all test cases across the project..."
2+
echo "Running all test cases across the project with coverage analysis..."
33

44
# Initialize a failure counter
55
failure_count=0
@@ -10,10 +10,21 @@ excluded_dirs="document_classifier functional_tests"
1010
# Find all test files except those in excluded directories
1111
test_files=$(find . -type f -name "test_*.py" | grep -Ev "$(echo $excluded_dirs | sed 's/ /|/g')")
1212

13-
# Run each test file
13+
# Begin coverage tracking
14+
coverage erase # Clear any existing coverage data
15+
16+
# Setup .coveragerc configuration to include all Python files
17+
echo "[run]
18+
source = .
19+
include = */*.py
20+
21+
[report]
22+
show_missing = True" > .coveragerc
23+
24+
# Run each test file with coverage
1425
for test_file in $test_files; do
1526
echo "Running $test_file..."
16-
pytest "$test_file"
27+
coverage run --append -m pytest "$test_file" # Using settings from .coveragerc
1728

1829
# Check the exit status of pytest
1930
if [ $? -ne 0 ]; then
@@ -22,10 +33,15 @@ for test_file in $test_files; do
2233
fi
2334
done
2435

36+
# Generate coverage reports
37+
echo "Generating coverage report..."
38+
coverage report
39+
2540
# Report the results
2641
if [ $failure_count -ne 0 ]; then
27-
echo "$failure_count test(s) failed."
42+
echo "$failure_count test(s) failed. Refer to the terminal output for details."
2843
exit 1
2944
else
3045
echo "All tests passed successfully!"
46+
echo "Coverage summary has been output to the terminal."
3147
fi

requirements/local.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pytest==8.0.0 # https://github.com/pytest-dev/pytest
1313
pytest-sugar==1.0.0 # https://github.com/Frozenball/pytest-sugar
1414
types-requests # maybe instead, we should add `mypy --install-types` to the dockerfile?
1515
types-xmltodict
16+
coverage
1617

1718
# Documentation
1819
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)