-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaccounts_test.py
More file actions
60 lines (47 loc) · 1.93 KB
/
accounts_test.py
File metadata and controls
60 lines (47 loc) · 1.93 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from unittest import TestCase
from mock import Mock
from mock import patch
from pybutton.resources import Accounts
config = {
'hostname': 'api.usebutton.com',
'secure': True,
'port': 443,
'timeout': None,
}
class AccountsTestCase(TestCase):
def test_all(self):
account = Accounts('sk-XXX', config)
account_response = [{'a': 1}, {'b': 2}]
api_get = Mock()
api_get.return_value = account_response
with patch.object(account, 'api_get', api_get):
response = account.all()
self.assertEqual(response, account_response)
api_get.assert_called_with('/v1/affiliation/accounts')
def test_transactions(self):
account = Accounts('sk-XXX', config)
account_response = [{'a': 1}, {'b': 2}]
api_get = Mock()
api_get.return_value = account_response
with patch.object(account, 'api_get', api_get):
response = account.transactions('acc-123')
self.assertEqual(response, account_response)
self.assertEqual(
api_get.call_args[0][0],
'/v1/affiliation/accounts/acc-123/transactions'
)
response = account.transactions(
'acc-123',
cursor='abc',
start='2016-09-15T00:00:00.000Z',
end='2016-09-30T00:00:00.000Z'
)
self.assertEqual(response, account_response)
query = api_get.call_args[1]['query']
self.assertEqual(query['cursor'], 'abc')
self.assertEqual(query['start'], '2016-09-15T00:00:00.000Z')
self.assertEqual(query['end'], '2016-09-30T00:00:00.000Z')