Skip to content

Commit

Permalink
tests for niccokunzmann#97
Browse files Browse the repository at this point in the history
  • Loading branch information
tobixen committed Nov 2, 2022
1 parent c35ba2f commit d25b425
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/calendars/simple_journal.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BEGIN:VCALENDAR

This comment has been minimized.

Copy link
@niccokunzmann

niccokunzmann Nov 3, 2022

I would appreciate it if the files all start with issue_97

This comment has been minimized.

Copy link
@tobixen

tobixen Nov 3, 2022

Author Owner

I will fix

VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VJOURNAL
UID:19920901T130000Z-123409@host.com
DTSTAMP:19920901T130000Z
DTSTART:19920420
SUMMARY:Yearly Income Tax Report
DESCRIPTION:We made it this year too. Probably. What's the point of a recurring journal entry? Journals are supposed to describe past events, aren't they?
RRULE:FREQ=YEARLY
CLASS:CONFIDENTIAL
CATEGORIES:FAMILY,FINANCE
PRIORITY:1
END:VJOURNAL
END:VCALENDAR
15 changes: 15 additions & 0 deletions test/calendars/simple_todo.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VTODO
UID:19920901T130000Z-123408@host.com
DTSTAMP:19920901T130000Z
DTSTART:19920415T133000Z
DUE:19920516T045959Z

This comment has been minimized.

Copy link
@niccokunzmann

niccokunzmann Nov 3, 2022

So this is like DTEND, then...

This comment has been minimized.

Copy link
@tobixen

tobixen Nov 3, 2022

Author Owner

Yes, from a technical point of view, DUE in VTODO equals DTEND in VEVENT

SUMMARY:Yearly Income Tax Preparation
RRULE:FREQ=YEARLY
CLASS:CONFIDENTIAL
CATEGORIES:FAMILY,FINANCE
PRIORITY:1
END:VTODO
END:VCALENDAR
31 changes: 31 additions & 0 deletions test/test_simple_recurrent_todos_and_journals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest

This comment has been minimized.

Copy link
@niccokunzmann

niccokunzmann Nov 3, 2022

I would appreciate if the test is named test_issue_91_... and the docstring links to the issue.

from recurring_ical_events import DATE_MAX


def test_recurring_task_is_not_included1(calendars):
tasks = calendars.simple_todo.between((1989, 1, 1), (1991,1,1))
assert not tasks

def test_recurring_task_is_not_included2(calendars):
tasks = calendars.simple_todo.between((1998, 1, 1), (1998,4,14))
assert not tasks

def test_recurring_task_is_repeated(calendars):
events = calendars.simple_todo.between((1995, 1, 1), (2022,1,1))
assert len(events) == 7

## Hmm ... I hate copying code, there is most likely some smart way to reuse

This comment has been minimized.

Copy link
@niccokunzmann

niccokunzmann Nov 3, 2022

Yes. have a look at pytest.mark.parametrize() There are examples here, too. It can be put into one or two test functions.

## the code above, but whatever ...
def test_recurring_journal_is_not_included1(calendars):
tasks = calendars.simple_journal.between((1989, 1, 1), (1991,1,1))
assert not tasks

def test_recurring_journal_is_not_included2(calendars):
tasks = calendars.simple_journal.between((1998, 1, 1), (1998,4,14))
assert not tasks

def test_recurring_journal_is_repeated(calendars):

This comment has been minimized.

Copy link
@niccokunzmann

niccokunzmann Nov 3, 2022

The tests look alright for me. They should fail properly.

events = calendars.simple_journal.between((1995, 1, 1), (2022,1,1))
assert len(events) == 7


0 comments on commit d25b425

Please sign in to comment.