forked from arrow-py/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_tests.py
38 lines (21 loc) · 823 Bytes
/
api_tests.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
37
from chai import Chai
from datetime import datetime
from dateutil import tz
import time
from arrow import api, factory, arrow, util
class ModuleTests(Chai):
def test_get(self):
expect(api._factory.get).args(1, b=2).returns('result')
assertEqual(api.get(1, b=2), 'result')
def test_utcnow(self):
expect(api._factory.utcnow).returns('utcnow')
assertEqual(api.utcnow(), 'utcnow')
def test_now(self):
expect(api._factory.now).args('tz').returns('now')
assertEqual(api.now('tz'), 'now')
def test_factory(self):
class MockCustomArrowClass(arrow.Arrow):
pass
result = api.factory(MockCustomArrowClass)
assertIsInstance(result, factory.ArrowFactory)
assertIsInstance(result.utcnow(), MockCustomArrowClass)