aboutsummaryrefslogtreecommitdiff
path: root/tests/filters/test_datediff.py
blob: 845330b7d788bef2347e90c13db2d86ac3863785 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import pytest

import resumejson_converter.filters as filters


def test_datediff_only_one_parameter():
    with pytest.raises(TypeError):
        filters.datediff()


def test_datediff_only_one_parameter():
    with pytest.raises(TypeError):
        filters.datediff("Hello World")


def test_datediff_only_two_parameter():
    with pytest.raises(TypeError):
        filters.datediff("Hello World", "2019-01-02")


def test_datediff_false_end_date():
    with pytest.raises(ValueError):
        filters.datediff("Hello", "2019-01-02", "2019-01-02d")


def test_datediff_false_start_date():
    with pytest.raises(ValueError):
        filters.datediff("Hello", "2019-01-02a", "2019-01-02")


def test_datediff_one_year():
    assert filters.datediff(
         "Hello World!",
         "2018-01-02",
         "2019-01-03"
    ) == "Hello World! - 1 an"


def test_datediff_two_year():
    assert filters.datediff(
        "Hello World!",
        "2017-01-02",
        "2019-01-03"
    ) == "Hello World! - 2 ans"


def test_datediff_two_years():
    assert filters.datediff(
        "Hello World!",
        "2017-01-02",
        "2019-01-03"
    ) == "Hello World! - 2 ans"


def test_datediff_one_month():
    assert filters.datediff(
        "Hello World!",
        "2019-01-02",
        "2019-02-03"
    ) == "Hello World! - 1 mois"


def test_datediff_one_week():
    assert filters.datediff(
        "Hello World!",
        "2019-01-01",
        "2019-01-09"
    ) == "Hello World! - 1 semaine"


def test_datediff_two_weeks():
    assert filters.datediff(
        "Hello World!",
        "2019-01-01",
        "2019-01-16"
    ) == "Hello World! - 2 semaines"


def test_datediff_two_days():
    assert filters.datediff(
        "Hello World!",
        "2019-01-02",
        "2019-01-04"
    ) == "Hello World! - 2 jours"