mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 23:55:46 +02:00
Send daily birthday notifications, add more settings & configs, fix small bugs in database
This commit is contained in:
parent
393cc9c891
commit
da0e60ac4f
8 changed files with 105 additions and 12 deletions
34
tests/test_didier/test_utils/test_types/test_datetime.py
Normal file
34
tests/test_didier/test_utils/test_types/test_datetime.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from didier.utils.types.datetime import str_to_date
|
||||
|
||||
|
||||
def test_str_to_date_single_valid():
|
||||
"""Test parsing a string for a single possibility (default)"""
|
||||
result = str_to_date("23/11/2001")
|
||||
assert result == datetime.date(year=2001, month=11, day=23)
|
||||
|
||||
|
||||
def test_str_to_date_single_invalid():
|
||||
"""Test parsing a string for an invalid string"""
|
||||
# Invalid format
|
||||
with pytest.raises(ValueError):
|
||||
str_to_date("23/11/01")
|
||||
|
||||
# Invalid date
|
||||
with pytest.raises(ValueError):
|
||||
str_to_date("69/42/0")
|
||||
|
||||
|
||||
def test_str_to_date_multiple_valid():
|
||||
"""Test parsing a string for multiple possibilities"""
|
||||
result = str_to_date("23/11/01", formats=["%d/%m/%Y", "%d/%m/%y"])
|
||||
assert result == datetime.date(year=2001, month=11, day=23)
|
||||
|
||||
|
||||
def test_str_to_date_multiple_invalid():
|
||||
"""Test parsing a string for multiple possibilities when none are valid"""
|
||||
with pytest.raises(ValueError):
|
||||
str_to_date("2001/01/02", formats=["%d/%m/%Y", "%d/%m/%y"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue