File: test_to_text.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 (53 lines) | stat: -rw-r--r-- 1,123 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from recurrence import Rule
import recurrence


def test_rule_to_text_simple():
    assert Rule(
        recurrence.WEEKLY
    ).to_text() == 'weekly'


def test_rule_to_text_interval():
    assert Rule(
        recurrence.WEEKLY,
        interval=3
    ).to_text() == 'every 3 weeks'


def test_rule_to_text_oneoff():
    assert Rule(
        recurrence.WEEKLY,
        count=1
    ).to_text() == 'weekly, occuring once'


def test_rule_to_text_multiple():
    assert Rule(
        recurrence.WEEKLY,
        count=5
    ).to_text() == 'weekly, occuring 5 times'


def test_rule_to_text_yearly_bymonth():
    assert Rule(
        recurrence.YEARLY,
        bymonth=[1, 3],
    ).to_text() == 'annually, each January, March'

    assert Rule(
        recurrence.YEARLY,
        bymonth=[1, 3],
    ).to_text(True) == 'annually, each Jan, Mar'


def test_rule_to_text_yearly_byday():
    assert Rule(
        recurrence.YEARLY,
        byday=[1, 3],
    ).to_text() == 'annually, on the Tuesday, Thursday'

    assert Rule(
        recurrence.YEARLY,
        byday=[1, 3],
    ).to_text(True) == 'annually, on the Tue, Thu'