-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient_test.py
More file actions
88 lines (72 loc) · 2.1 KB
/
Copy pathclient_test.py
File metadata and controls
88 lines (72 loc) · 2.1 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from unittest import TestCase
from pybutton.client import Client
from pybutton.client import config_with_defaults
from pybutton import ButtonClientError
class ClientTestCase(TestCase):
def test_requires_api_key(self):
try:
Client()
self.assertTrue(False)
except TypeError:
pass
try:
Client('')
self.assertTrue(False)
except ButtonClientError:
pass
try:
Client(None)
self.assertTrue(False)
except ButtonClientError:
pass
def test_orders(self):
client = Client('sk-XXX')
self.assertTrue(client.orders is not None)
def test_config(self):
# Defaults
config = config_with_defaults({})
self.assertEqual(config, {
'hostname': 'api.usebutton.com',
'port': 443,
'secure': True,
'timeout': None,
'api_version': None,
})
# Port and timeout overrides
config = config_with_defaults({
'port': 88,
'timeout': 5,
})
self.assertEqual(config, {
'hostname': 'api.usebutton.com',
'port': 88,
'secure': True,
'timeout': 5,
'api_version': None,
})
# Hostname and secure overrides
config = config_with_defaults({
'hostname': 'localhost',
'secure': False,
})
self.assertEqual(config, {
'hostname': 'localhost',
'port': 80,
'secure': False,
'timeout': None,
'api_version': None,
})
config = config_with_defaults({
'api_version': '2017-01-01',
})
self.assertEqual(config, {
'hostname': 'api.usebutton.com',
'port': 443,
'secure': True,
'timeout': None,
'api_version': '2017-01-01',
})