Buckets:
| """Tests for shared theme constants.""" | |
| import pytest | |
| from faultray.theme import ( | |
| HEALTH_COLORS, | |
| SCORE_COLORS, | |
| SEVERITY_COLORS, | |
| score_to_color, | |
| severity_to_color, | |
| ) | |
| class TestSeverityColors: | |
| """Verify severity color lookups.""" | |
| def test_all_severity_levels_present(self): | |
| expected = {"critical", "high", "medium", "low", "info"} | |
| assert set(SEVERITY_COLORS.keys()) == expected | |
| def test_critical_is_red(self): | |
| assert SEVERITY_COLORS["critical"] == "#dc3545" | |
| def test_low_is_green(self): | |
| assert SEVERITY_COLORS["low"] == "#28a745" | |
| class TestHealthColors: | |
| """Verify health color lookups.""" | |
| def test_all_health_statuses_present(self): | |
| expected = {"healthy", "degraded", "overloaded", "down"} | |
| assert set(HEALTH_COLORS.keys()) == expected | |
| def test_healthy_is_green(self): | |
| assert HEALTH_COLORS["healthy"] == "#28a745" | |
| def test_down_is_red(self): | |
| assert HEALTH_COLORS["down"] == "#dc3545" | |
| class TestScoreToColor: | |
| """Verify score_to_color returns correct color bands.""" | |
| def test_score_bands(self, score, expected_key): | |
| assert score_to_color(score) == SCORE_COLORS[expected_key] | |
| def test_negative_score(self): | |
| # Negative scores should map to critical | |
| assert score_to_color(-10.0) == SCORE_COLORS["critical"] | |
| def test_above_100_score(self): | |
| # Scores above 100 should map to excellent | |
| assert score_to_color(150.0) == SCORE_COLORS["excellent"] | |
| class TestSeverityToColor: | |
| """Verify severity_to_color with case-insensitive lookup.""" | |
| def test_lowercase(self): | |
| assert severity_to_color("critical") == "#dc3545" | |
| def test_uppercase(self): | |
| assert severity_to_color("CRITICAL") == "#dc3545" | |
| def test_mixed_case(self): | |
| assert severity_to_color("High") == "#fd7e14" | |
| def test_unknown_returns_default(self): | |
| assert severity_to_color("unknown") == "#8b949e" | |
| def test_empty_string_returns_default(self): | |
| assert severity_to_color("") == "#8b949e" | |
Xet Storage Details
- Size:
- 2.47 kB
- Xet hash:
- 36bd260d38f17baa342f0b03741126af68b2f8674f959182e428b52af5761808
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.