File: test_timedelta_for_between.py

package info (click to toggle)
python-recurring-ical-events 3.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,128 kB
  • sloc: python: 2,896; sh: 15; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""This tests that a timedelta can be used as the second argument to between.

This is useful when you do not want to calculate this yourself.
"""

from datetime import timedelta

import pytest


@pytest.mark.parametrize(
    ("start", "delta", "count"),
    [
        ("20190301", timedelta(days=3), 0),
        ("20190301", timedelta(days=5), 1),
        ("20190301", timedelta(days=3, hours=8), 0),
        ("20190301", timedelta(days=3, hours=9), 1),
        ("20190301", timedelta(days=3, hours=8, seconds=1), 1),
        ("20190304", timedelta(days=1), 1),
        ("20190304", timedelta(hours=8), 0),
        ("20190304", timedelta(hours=9), 1),
    ],
)
def test_event_with_between_and_timedelta(calendars, start, delta, count):
    """The event starts at 20190304T080000 and ends at 20190304T080000"""
    events = calendars.one_event.between(start, delta)
    assert len(events) == count