comparison tests/unit/test_plugin_xep_0082.py @ 3933:cecf45416403

plugin XEP-0373 and XEP-0374: Implementation of OX and OXIM: GPGME is used as the GPG provider. rel 374
author Syndace <me@syndace.dev>
date Tue, 20 Sep 2022 16:22:18 +0200
parents 8289ac1b34f4
children 4b842c1fb686
comparison
equal deleted inserted replaced
3932:7af29260ecb8 3933:cecf45416403
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 18
19 from datetime import date, datetime, time, timezone 19 from datetime import date, datetime, time, timezone
20 20
21 import pytest 21 import pytest
22 from sat.core import exceptions
22 23
23 from sat.plugins.plugin_xep_0082 import XEP_0082 24 from sat.plugins.plugin_xep_0082 import XEP_0082
24 25
25 26
26 __all__ = [ # pylint: disable=unused-variable 27 __all__ = [ # pylint: disable=unused-variable
102 103
103 # With timezone '-05:00', without a fraction of a second 104 # With timezone '-05:00', without a fraction of a second
104 assert XEP_0082.parse_datetime("1969-07-20T21:56:15-05:00") == value 105 assert XEP_0082.parse_datetime("1969-07-20T21:56:15-05:00") == value
105 106
106 # Without timezone, without a fraction of a second 107 # Without timezone, without a fraction of a second
107 with pytest.raises(ValueError): 108 with pytest.raises(exceptions.ParsingError):
108 XEP_0082.parse_datetime("1969-07-21T02:56:15") 109 XEP_0082.parse_datetime("1969-07-21T02:56:15")
109 110
110 # With timezone 'Z', with a fraction of a second consisting of two digits 111 # With timezone 'Z', with a fraction of a second consisting of two digits
111 assert XEP_0082.parse_datetime("1969-07-21T02:56:15.12Z") == \ 112 assert XEP_0082.parse_datetime("1969-07-21T02:56:15.12Z") == \
112 value.replace(microsecond=120000) 113 value.replace(microsecond=120000)
121 122
122 # With timezone '-05:00', with a fraction of a second consisting of zero digits 123 # With timezone '-05:00', with a fraction of a second consisting of zero digits
123 assert XEP_0082.parse_datetime("1969-07-20T21:56:15.-05:00") == value 124 assert XEP_0082.parse_datetime("1969-07-20T21:56:15.-05:00") == value
124 125
125 # Without timezone, with a fraction of a second consisting of six digits 126 # Without timezone, with a fraction of a second consisting of six digits
126 with pytest.raises(ValueError): 127 with pytest.raises(exceptions.ParsingError):
127 XEP_0082.parse_datetime("1969-07-21T02:56:15.123456") 128 XEP_0082.parse_datetime("1969-07-21T02:56:15.123456")
128 129
129 130
130 def test_time_formatting() -> None: # pylint: disable=missing-function-docstring 131 def test_time_formatting() -> None: # pylint: disable=missing-function-docstring
131 # The following tests don't check the output of format_time directly; instead, they 132 # The following tests don't check the output of format_time directly; instead, they