forked from SynapseFI/SynapseFI-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_tests.py
More file actions
49 lines (43 loc) · 1.83 KB
/
client_tests.py
File metadata and controls
49 lines (43 loc) · 1.83 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
import unittest
from synapse_pay_rest.client import Client
from synapse_pay_rest.http_client import HttpClient
from synapse_pay_rest.api.users import Users
from synapse_pay_rest.api.nodes import Nodes
from synapse_pay_rest.api.trans import Trans
from synapse_pay_rest.tests.fixtures.client import *
class ClientTestCases(unittest.TestCase):
def setUp(self):
print('\n{0}.{1}'.format(type(self).__name__, self._testMethodName))
self.client = Client(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
fingerprint=FINGERPRINT,
ip_address=IP_ADDRESS,
development_mode=True,
logging=True
)
def test_properties(self):
self.assertIsInstance(self.client.http_client, HttpClient)
self.assertIsInstance(self.client.users, Users)
self.assertIsInstance(self.client.nodes, Nodes)
self.assertIsInstance(self.client.trans, Trans)
def test_passes_correct_base_url_to_http_client(self):
sandbox = 'https://uat-api.synapsefi.com/v3.1'
production = 'https://synapsepay.com/api/3'
self.assertEqual(sandbox, self.client.http_client.base_url)
prod_client = Client(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
fingerprint=FINGERPRINT,
ip_address=IP_ADDRESS,
development_mode=False,
logging=True
)
self.assertEqual(production, prod_client.http_client.base_url)
def test_passes_header_info_to_http_client(self):
headers = self.client.http_client.headers
gateway = CLIENT_ID + '|' + CLIENT_SECRET
user = '|' + FINGERPRINT
self.assertEqual(gateway, headers['X-SP-GATEWAY'])
self.assertEqual(user, headers['X-SP-USER'])
self.assertEqual(IP_ADDRESS, headers['X-SP-USER-IP'])