2024-10-16 21:58:22 +00:00
|
|
|
import datetime
|
2024-10-23 19:30:23 +00:00
|
|
|
|
2024-10-16 21:58:22 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from obsidian_import import obsidian
|
|
|
|
|
2024-11-24 16:08:19 +00:00
|
|
|
from .test_obsidian_vault import EXAMPLES, EXAMPLE_DATE, EXAMPLE_TIMEZONE
|
2024-10-23 19:30:23 +00:00
|
|
|
|
2024-11-24 16:49:00 +00:00
|
|
|
|
|
|
|
def test_parse_event_string():
|
|
|
|
formatted = '17:44 | Watched [[../../media/anime/Azumanga Daioh]]. Season 1 Episode 6: *Sports Fest*'
|
|
|
|
|
|
|
|
event = obsidian.parse_event_string(formatted, EXAMPLE_DATE, EXAMPLE_TIMEZONE)
|
|
|
|
assert event is not None
|
|
|
|
assert event.subject == 'Azumanga Daioh'
|
|
|
|
assert event.start_time is not None
|
|
|
|
|
2024-10-23 19:30:23 +00:00
|
|
|
@pytest.mark.parametrize('event', EXAMPLES)
|
2024-10-16 21:58:22 +00:00
|
|
|
def test_format_preserves_information(event: obsidian.Event):
|
2024-11-24 16:08:19 +00:00
|
|
|
formatted = obsidian.format_event_string(event, EXAMPLE_TIMEZONE)
|
|
|
|
assert obsidian.parse_event_string(formatted, EXAMPLE_DATE,
|
|
|
|
EXAMPLE_TIMEZONE) == event
|