diff options
author | neodarz <neodarz@neodarz.net> | 2019-08-04 11:54:08 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2019-08-04 11:54:08 +0200 |
commit | 01b15786a8ae02d364ff79011473bde90eb42e76 (patch) | |
tree | b8b3b776d10bc56a992e6a5d407554987f4b66c0 /tests/filters | |
parent | 532e7042a7b6d0f5725778de950745bc7f227df2 (diff) | |
download | resumejson_converter-01b15786a8ae02d364ff79011473bde90eb42e76.tar.xz resumejson_converter-01b15786a8ae02d364ff79011473bde90eb42e76.zip |
Add some tests
Diffstat (limited to 'tests/filters')
-rw-r--r-- | tests/filters/test_birthday.py | 17 | ||||
-rw-r--r-- | tests/filters/test_clean.py | 12 | ||||
-rw-r--r-- | tests/filters/test_datediff.py | 84 | ||||
-rw-r--r-- | tests/filters/test_dateedit.py | 30 |
4 files changed, 143 insertions, 0 deletions
diff --git a/tests/filters/test_birthday.py b/tests/filters/test_birthday.py new file mode 100644 index 0000000..257f8c4 --- /dev/null +++ b/tests/filters/test_birthday.py @@ -0,0 +1,17 @@ +import pytest + +import resumejson_converter.filters as filters + + +def test_birthday_no_parameter(): + with pytest.raises(TypeError): + filters.birthday() + + +def test_birthday_false_date(): + with pytest.raises(ValueError): + filters.birthday("1990-10-25a") + + +def test_birthday(): + assert filters.birthday("1990-10-25") == "25 octobre 1990" diff --git a/tests/filters/test_clean.py b/tests/filters/test_clean.py new file mode 100644 index 0000000..32553b4 --- /dev/null +++ b/tests/filters/test_clean.py @@ -0,0 +1,12 @@ +import pytest + +import resumejson_converter.filters as filters + + +def test_clean_no_parameter(): + with pytest.raises(TypeError): + filters.clean() + + +def test_clean(): + assert filters.clean("0011223344") == "00 11 22 33 44" diff --git a/tests/filters/test_datediff.py b/tests/filters/test_datediff.py new file mode 100644 index 0000000..845330b --- /dev/null +++ b/tests/filters/test_datediff.py @@ -0,0 +1,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" diff --git a/tests/filters/test_dateedit.py b/tests/filters/test_dateedit.py new file mode 100644 index 0000000..5191b26 --- /dev/null +++ b/tests/filters/test_dateedit.py @@ -0,0 +1,30 @@ +import pytest + +import resumejson_converter.filters as filters + + +def test_dateedit_only_one_parameter(): + with pytest.raises(TypeError): + filters.dateedit() + + +def test_dateedit_only_one_parameter(): + with pytest.raises(TypeError): + filters.dateedit("2019-01-01") + + +def test_dateedit_false_date(): + with pytest.raises(ValueError): + filters.dateedit("2019-01-01i", "") + + +def test_dateedit_only_start_date(): + assert filters.dateedit("2019-01-01", "") == "2019 - Auj." + + +def test_dateedite_same_year(): + assert filters.dateedit("2019-01-01", "2019-02-02") == "2019" + + +def test_dateedit_start_date_and_end_date_different(): + assert filters.dateedit("2019-01-01", "2017-05-01") == "2019 - 2017" |