-
-
Notifications
You must be signed in to change notification settings - Fork 692
/
Copy pathtest_api.py
36 lines (24 loc) · 1017 Bytes
/
test_api.py
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
import arrow
class TestModule:
def test_get(self, mocker):
mocker.patch("arrow.api._factory.get", return_value="result")
assert arrow.api.get() == "result"
def test_utcnow(self, mocker):
mocker.patch("arrow.api._factory.utcnow", return_value="utcnow")
assert arrow.api.utcnow() == "utcnow"
def test_now(self, mocker):
mocker.patch("arrow.api._factory.now", tz="tz", return_value="now")
assert arrow.api.now("tz") == "now"
def test_factory(self):
class MockCustomArrowClass(arrow.Arrow):
pass
result = arrow.api.factory(MockCustomArrowClass)
assert isinstance(result, arrow.factory.ArrowFactory)
assert isinstance(result.utcnow(), MockCustomArrowClass)
def test_timezone(self, mocker):
mocker.patch(
"arrow.api._factory.timezone",
zone_name="zone_name",
return_value="timezone",
)
assert arrow.api.timezone("zone_name") == "timezone"