2023-04-05 21:57:31 +02:00
|
|
|
#!/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:
|
2024-11-21 23:26:07 +01:00
|
|
|
"""Test timestamp_to_date() with a correct timestamp."""
|
2023-04-05 21:57:31 +02:00
|
|
|
timestamp: int = 1680722218
|
|
|
|
result: str = timestamp_to_date(timestamp)
|
|
|
|
assert result == "2023-04-05"
|
|
|
|
|
|
|
|
|
|
|
|
def test_invalid() -> None:
|
2024-11-21 23:26:07 +01:00
|
|
|
"""Test timestamp_to_date() with an invalid timestamp."""
|
2023-04-05 21:57:31 +02:00
|
|
|
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)
|