diff options
| author | rr- | 2016-04-20 11:58:17 +0200 |
|---|---|---|
| committer | rr- | 2016-04-20 11:58:17 +0200 |
| commit | 57b18c64612524fec2ad5e4b780ca2cd605e05ab (patch) | |
| tree | 01d791ff29c32c36ff507fd5aee094cfd13c52ed /server/szurubooru/tests/func/test_misc.py | |
| parent | d3f2ef296b2bdd99be3af90d77efb95c8898e784 (diff) | |
server/general: rename 'util' to 'func'
Diffstat (limited to 'server/szurubooru/tests/func/test_misc.py')
| -rw-r--r-- | server/szurubooru/tests/func/test_misc.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/server/szurubooru/tests/func/test_misc.py b/server/szurubooru/tests/func/test_misc.py new file mode 100644 index 0000000..fc04bdb --- /dev/null +++ b/server/szurubooru/tests/func/test_misc.py @@ -0,0 +1,36 @@ +import pytest +from szurubooru import errors +from szurubooru.func import misc +from datetime import datetime + +dt = datetime + +def test_parsing_empty_date_time(): + with pytest.raises(errors.ValidationError): + misc.parse_time_range('') + +@pytest.mark.parametrize('input,output', [ + ('today', (dt(1997, 1, 2, 0, 0, 0), dt(1997, 1, 2, 23, 59, 59))), + ('yesterday', (dt(1997, 1, 1, 0, 0, 0), dt(1997, 1, 1, 23, 59, 59))), + ('1999', (dt(1999, 1, 1, 0, 0, 0), dt(1999, 12, 31, 23, 59, 59))), + ('1999-2', (dt(1999, 2, 1, 0, 0, 0), dt(1999, 2, 28, 23, 59, 59))), + ('1999-02', (dt(1999, 2, 1, 0, 0, 0), dt(1999, 2, 28, 23, 59, 59))), + ('1999-2-6', (dt(1999, 2, 6, 0, 0, 0), dt(1999, 2, 6, 23, 59, 59))), + ('1999-02-6', (dt(1999, 2, 6, 0, 0, 0), dt(1999, 2, 6, 23, 59, 59))), + ('1999-2-06', (dt(1999, 2, 6, 0, 0, 0), dt(1999, 2, 6, 23, 59, 59))), + ('1999-02-06', (dt(1999, 2, 6, 0, 0, 0), dt(1999, 2, 6, 23, 59, 59))), +]) +def test_parsing_date_time(fake_datetime, input, output): + with fake_datetime('1997-01-02 03:04:05'): + assert misc.parse_time_range(input) == output + +@pytest.mark.parametrize('input,output', [ + ([], []), + (['a', 'b', 'c'], ['a', 'b', 'c']), + (['a', 'b', 'a'], ['a', 'b']), + (['a', 'a', 'b'], ['a', 'b']), + (['a', 'A', 'b'], ['a', 'b']), + (['a', 'A', 'b', 'B'], ['a', 'b']), +]) +def test_icase_unique(input, output): + assert misc.icase_unique(input) == output |