Skip to content

Commit f89a4be

Browse files
committed
feat(tests): add comprehensive error scenario coverage
- Created 36 new error scenario tests covering configuration validation, network failures, and edge cases - Added configuration error testing for invalid settings, empty values, and malformed configurations - Implemented network error scenario testing including timeouts, connection failures, and HTTP errors - Added subprocess execution error testing for CLI failures, permission errors, and process management - Created file system error scenario testing for permission issues, disk space problems, and path handling - Added concurrency and race condition testing for ProcessManager and version caching - Implemented edge case testing for Unicode paths, extremely long paths, and zero-byte downloads - Enhanced error handling validation across all management commands and utility functions - Fixed config tests to properly clear cache and mock network requests for consistent fallback behavior - Improved test coverage to 89% with comprehensive error scenario validation
1 parent a6741e9 commit f89a4be

File tree

4 files changed

+737
-3
lines changed

4 files changed

+737
-3
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@
4848
- Implemented verbose logging integration tests across all management commands
4949
- Enhanced test coverage to 87% with comprehensive workflow validation
5050
- Fixed coverage configuration issues to ensure consistent test reporting
51+
- Added comprehensive error scenario coverage for enhanced reliability and robustness.
52+
- Created 36 new error scenario tests covering configuration validation, network failures, and edge cases
53+
- Added configuration error testing for invalid settings, empty values, and malformed configurations
54+
- Implemented network error scenario testing including timeouts, connection failures, and HTTP errors
55+
- Added subprocess execution error testing for CLI failures, permission errors, and process management
56+
- Created file system error scenario testing for permission issues, disk space problems, and path handling
57+
- Added concurrency and race condition testing for ProcessManager and version caching
58+
- Implemented edge case testing for Unicode paths, extremely long paths, and zero-byte downloads
59+
- Enhanced error handling validation across all management commands and utility functions
60+
- Fixed config tests to properly clear cache and mock network requests for consistent fallback behavior
61+
- Improved test coverage to 89% with comprehensive error scenario validation
5162

5263
## 4.2.4
5364

tests/test_config.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@ def configure_settings(
2626
],
2727
)
2828
def test_get_version(
29-
settings: SettingsWrapper, version_str: str, expected_version_str: str, version: tuple[int, int, int]
29+
settings: SettingsWrapper, version_str: str, expected_version_str: str, version: tuple[int, int, int], mocker: MockerFixture
3030
):
3131
settings.TAILWIND_CLI_VERSION = version_str
32+
33+
# For "latest" version test, mock the network request to ensure fallback
34+
if version_str == "latest":
35+
# Clear any existing cache
36+
from django_tailwind_cli.config import _get_cache_path
37+
cache_path = _get_cache_path()
38+
if cache_path.exists():
39+
cache_path.unlink()
40+
41+
# Mock failed network request to force fallback
42+
request_get = mocker.patch("requests.get")
43+
request_get.return_value.ok = False
44+
3245
r_version_str, r_version = get_version()
3346
assert r_version_str == expected_version_str
3447
assert r_version.major == version[0]
@@ -37,6 +50,12 @@ def test_get_version(
3750

3851

3952
def test_get_version_latest_without_proper_http_response(mocker: MockerFixture):
53+
# Clear any existing cache
54+
from django_tailwind_cli.config import _get_cache_path
55+
cache_path = _get_cache_path()
56+
if cache_path.exists():
57+
cache_path.unlink()
58+
4059
request_get = mocker.patch("requests.get")
4160
request_get.return_value.ok = False
4261

@@ -48,6 +67,12 @@ def test_get_version_latest_without_proper_http_response(mocker: MockerFixture):
4867

4968

5069
def test_get_version_latest_without_redirect(mocker: MockerFixture):
70+
# Clear any existing cache
71+
from django_tailwind_cli.config import _get_cache_path
72+
cache_path = _get_cache_path()
73+
if cache_path.exists():
74+
cache_path.unlink()
75+
5176
request_get = mocker.patch("requests.get")
5277
request_get.return_value.headers = {}
5378

0 commit comments

Comments
 (0)