diff options
Diffstat (limited to 'tests/unit/test_strings.py')
-rw-r--r-- | tests/unit/test_strings.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_strings.py b/tests/unit/test_strings.py index a0b5617..835a508 100644 --- a/tests/unit/test_strings.py +++ b/tests/unit/test_strings.py | |||
@@ -23,10 +23,28 @@ def test_string_to_absolute_time(datestr, expected): | |||
23 | dt = strings.string_to_absolute_time(datestr) | 23 | dt = strings.string_to_absolute_time(datestr) |
24 | assert dt.timetuple()[:6] == expected | 24 | assert dt.timetuple()[:6] == expected |
25 | 25 | ||
26 | |||
26 | def test_string_to_absolute_time_end_of_time(): | 27 | def test_string_to_absolute_time_end_of_time(): |
27 | assert strings.string_to_absolute_time("end of time") is None | 28 | assert strings.string_to_absolute_time("end of time") is None |
28 | 29 | ||
30 | |||
29 | def test_string_to_absolute_invalid(): | 31 | def test_string_to_absolute_invalid(): |
30 | with pytest.raises(ValueError) as excinfo: | 32 | with pytest.raises(ValueError) as excinfo: |
31 | strings.string_to_absolute_time("asdfgh") | 33 | strings.string_to_absolute_time("asdfgh") |
32 | assert str(excinfo.value).startswith("asdfgh is not a properly formatted") | 34 | assert str(excinfo.value).startswith("asdfgh is not a properly formatted") |
35 | |||
36 | |||
37 | def test_data_to_string(): | ||
38 | assert strings.data_to_string(b"") == "" | ||
39 | assert strings.data_to_string(b"dfgzu") == "CHJ6EUJL" | ||
40 | |||
41 | |||
42 | def test_string_to_data(): | ||
43 | assert strings.string_to_data("") == b"" | ||
44 | assert strings.string_to_data("CHJ6EUJL") == b"dfgzu" | ||
45 | with pytest.raises(ValueError) as excinfo: | ||
46 | strings.string_to_data("asdfgh") | ||
47 | assert "is not a valid data-encoding string" in str(excinfo.value) | ||
48 | with pytest.raises(ValueError) as excinfo: | ||
49 | strings.string_to_data(["asdfgh"]) | ||
50 | assert "is not a valid data-encoding string" in str(excinfo.value) | ||