Files
thc-webhook/tests/test_templates.py
T
zwitschi e30920067f
Build and Deploy Docker Container / build-and-deploy (push) Failing after 3m8s
Test Application / test (push) Failing after 28s
feat: Add dashboard support and enhance Discord webhook functionality
- Updated docker-compose.yml to expose dashboard on port 8080.
- Enhanced main.py with timezone database caching and improved state management.
- Introduced a minimal dashboard using Flask to display webhook status and notifications.
- Added templates.json for customizable embed messages in Discord notifications.
- Created templates.py for loading and saving notification templates.
- Implemented tests for dashboard rendering and main functionality.
- Added requirements for Flask and tzdata to support new features.
- Included test cases for timezone handling and template management.
2026-05-09 21:59:52 +02:00

28 lines
872 B
Python

from templates import DEFAULT_TEMPLATES, load_templates, parse_color, save_templates
def test_parse_color():
assert parse_color("#e67e22") == 0xE67E22
assert parse_color("e67e22") == 0xE67E22
assert parse_color("0xe67e22") == 0xE67E22
assert parse_color("15158306") == 15158306
def test_load_templates_missing_file(tmp_path):
templates = load_templates(tmp_path / "missing.json")
assert templates["420"]["text"] == DEFAULT_TEMPLATES["420"]["text"]
def test_save_and_load_templates_roundtrip(tmp_path):
path = tmp_path / "templates.json"
data = {
"420": {"text": "Custom", "color": 123},
}
save_templates(path, data)
loaded = load_templates(path)
assert loaded["420"]["text"] == "Custom"
assert loaded["420"]["color"] == 123
# defaults should still exist for other keys
assert "reminder" in loaded