Generalized testing
This commit is contained in:
parent
8d9e6aefa4
commit
05c870402d
|
@ -4,27 +4,10 @@ import pytest
|
||||||
|
|
||||||
from obsidian_import import obsidian
|
from obsidian_import import obsidian
|
||||||
|
|
||||||
EXAMPLES = [
|
from .test_obsidian_vault import EXAMPLES, EXAMPLE_DATE, EXAMPLE_TIMEZONE
|
||||||
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]].'),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('event', EXAMPLES)
|
@pytest.mark.parametrize('event', EXAMPLES)
|
||||||
def test_format_preserves_information(event: obsidian.Event):
|
def test_format_preserves_information(event: obsidian.Event):
|
||||||
formatted = obsidian.format_event_string(event)
|
formatted = obsidian.format_event_string(event, EXAMPLE_TIMEZONE)
|
||||||
assert obsidian.parse_event_string(formatted) == event
|
assert obsidian.parse_event_string(formatted, EXAMPLE_DATE,
|
||||||
|
EXAMPLE_TIMEZONE) == event
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
import datetime
|
import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
from obsidian_import import obsidian
|
from obsidian_import import obsidian
|
||||||
|
|
||||||
|
EXAMPLE_TIMEZONE = ZoneInfo('Europe/Copenhagen')
|
||||||
|
|
||||||
|
EXAMPLE_DATE = datetime.date(2020, 1, 1)
|
||||||
|
|
||||||
EXAMPLES = [
|
EXAMPLES = [
|
||||||
obsidian.Event(
|
obsidian.Event(
|
||||||
datetime.time(12, 0, 0),
|
datetime.datetime(2020, 1, 1, 12, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
|
||||||
datetime.time(12, 0, 0),
|
datetime.datetime(2020, 1, 1, 12, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
|
||||||
'Ate',
|
'Ate',
|
||||||
'Lunch',
|
'Lunch',
|
||||||
'instantly',
|
'instantly',
|
||||||
),
|
),
|
||||||
obsidian.Event(
|
obsidian.Event(
|
||||||
datetime.time(20, 0, 0),
|
datetime.datetime(2020, 1, 1, 20, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
|
||||||
datetime.time(22, 0, 0),
|
datetime.datetime(2020, 1, 1, 22, 0, 0, tzinfo=EXAMPLE_TIMEZONE),
|
||||||
'Watched',
|
'Watched',
|
||||||
'Tom and Jerry',
|
'Tom and Jerry',
|
||||||
'on the *Television*',
|
'on the *Television*',
|
||||||
|
@ -33,7 +38,7 @@ def test_write_internally():
|
||||||
vault.path_format = 'YYYY-MM-DD'
|
vault.path_format = 'YYYY-MM-DD'
|
||||||
vault.template_file_path = Path('daily-template-file.md')
|
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 len(vault.internal_file_text_cache) == 2
|
||||||
|
|
||||||
assert vault.internal_file_text_cache[
|
assert vault.internal_file_text_cache[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user