1
0

Generalized testing

This commit is contained in:
Jon Michael Aanes 2024-11-24 17:08:19 +01:00
parent 8d9e6aefa4
commit 05c870402d
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 14 additions and 26 deletions

View File

@ -4,27 +4,10 @@ import pytest
from obsidian_import import obsidian
EXAMPLES = [
obsidian.Event(
datetime.time(12, 0, 0),
datetime.time(12, 0, 0),
'Ate',
'Lunch',
'instantly',
),
obsidian.Event(
datetime.time(20, 0, 0),
datetime.time(22, 0, 0),
'Watched',
'Tom and Jerry',
'on the *Television*',
),
obsidian.Event(None, None, None, None, 'Took a walk'),
obsidian.Event(None, None, None, None, 'Watched [[Cyberpunk: Edgerunners]].'),
]
from .test_obsidian_vault import EXAMPLES, EXAMPLE_DATE, EXAMPLE_TIMEZONE
@pytest.mark.parametrize('event', EXAMPLES)
def test_format_preserves_information(event: obsidian.Event):
formatted = obsidian.format_event_string(event)
assert obsidian.parse_event_string(formatted) == event
formatted = obsidian.format_event_string(event, EXAMPLE_TIMEZONE)
assert obsidian.parse_event_string(formatted, EXAMPLE_DATE,
EXAMPLE_TIMEZONE) == event

View File

@ -1,19 +1,24 @@
import datetime
from pathlib import Path
from zoneinfo import ZoneInfo
from obsidian_import import obsidian
EXAMPLE_TIMEZONE = ZoneInfo('Europe/Copenhagen')
EXAMPLE_DATE = datetime.date(2020, 1, 1)
EXAMPLES = [
obsidian.Event(
datetime.time(12, 0, 0),
datetime.time(12, 0, 0),
datetime.datetime(2020, 1, 1, 12, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
datetime.datetime(2020, 1, 1, 12, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
'Ate',
'Lunch',
'instantly',
),
obsidian.Event(
datetime.time(20, 0, 0),
datetime.time(22, 0, 0),
datetime.datetime(2020, 1, 1, 20, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
datetime.datetime(2020, 1, 1, 22, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
'Watched',
'Tom and Jerry',
'on the *Television*',
@ -33,7 +38,7 @@ def test_write_internally():
vault.path_format = 'YYYY-MM-DD'
vault.template_file_path = Path('daily-template-file.md')
vault.add_events(datetime.date(2020, 1, 1), EXAMPLES)
vault.add_events(EXAMPLE_DATE, EXAMPLES)
assert len(vault.internal_file_text_cache) == 2
assert vault.internal_file_text_cache[