Generalized testing
This commit is contained in:
parent
8d9e6aefa4
commit
05c870402d
|
@ -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
|
||||
|
|
|
@ -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[
|
||||
|
|
Loading…
Reference in New Issue
Block a user