Initial
This commit is contained in:
29
tests/test_config.py
Normal file
29
tests/test_config.py
Normal file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Provides test cases for app/utils/config.py."""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
vars: dict = {
|
||||
"BOT_NAME": "TestBot",
|
||||
"WEBEX_API_KEY": "testing",
|
||||
"ADMIN_FIRST_NAME": "Test",
|
||||
"ADMIN_EMAIL": "test@test.com",
|
||||
"N8N_WEBHOOK_URL": "https://n8n.test.com/webhook/abcdefg",
|
||||
}
|
||||
|
||||
|
||||
for var, value in vars.items():
|
||||
os.environ[var] = value
|
||||
|
||||
# needs to be imported AFTER environment variables are set
|
||||
from app.utils.config import config # pragma: no cover
|
||||
|
||||
|
||||
def test_config() -> None:
|
||||
assert config.bot_name == vars["BOT_NAME"]
|
||||
assert config.webex_token == vars["WEBEX_API_KEY"]
|
||||
assert config.admin_first_name == vars["ADMIN_FIRST_NAME"]
|
||||
assert config.admin_emails == vars["ADMIN_EMAIL"].split(",")
|
||||
assert config.n8n_webhook_url == vars["N8N_WEBHOOK_URL"]
|
20
tests/test_datetime.py
Normal file
20
tests/test_datetime.py
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Provides test cases for app/utils/datetime.py."""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.utils.datetime import timestamp_to_date # pragma: no cover
|
||||
|
||||
|
||||
def test_correct() -> None:
|
||||
timestamp: int = 1680722218
|
||||
result: str = timestamp_to_date(timestamp)
|
||||
assert result == "2023-04-05"
|
||||
|
||||
|
||||
def test_invalid() -> None:
|
||||
timestamp: str = "hello"
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
timestamp_to_date(timestamp)
|
||||
assert "'str' object cannot be interpreted as an integer" in str(excinfo.value)
|
Reference in New Issue
Block a user