File: test_weekday.py

package info (click to toggle)
django-recurrence 1.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,148 kB
  • sloc: python: 2,530; javascript: 2,502; makefile: 159; sh: 6
file content (24 lines) | stat: -rw-r--r-- 550 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest
from recurrence import Weekday


def test_init():
    assert repr(Weekday(3)) == 'TH'
    assert repr(Weekday(3, -2)) == '-2TH'
    assert repr(Weekday(3, 3)) == '3TH'

    with pytest.raises(ValueError):
        Weekday(8)

    with pytest.raises(ValueError):
        Weekday('fish')


def test_call():
    # I'm not sure why this functionality is useful, but this is what
    # calling a weekday currently does.

    day = Weekday(4, -3)
    assert day(2) == Weekday(4, 2)
    assert day(-3) is day
    assert day(None) == Weekday(4)