forked from gopaycommunity/gopay-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
41 lines (32 loc) · 1.1 KB
/
__init__.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
38
39
40
41
from gopay import payments, add_defaults
from hamcrest import *
import sys
if sys.version_info < (3, 0):
from test.test_support import EnvironmentVarGuard
else:
from test.support import EnvironmentVarGuard
def given_client(config=None):
env = EnvironmentVarGuard()
return payments(
add_defaults(config, {
'goid': env.get('goid'),
'clientId': env.get('clientId'),
'clientSecret': env.get('clientSecret'),
'isProductionMode': False
}),
{
'logger': debug_logger
}
)
def should_return(response, field, expected_value):
assert_that(response.has_succeed(), is_(True))
assert_that(response.status_code, is_(200))
assert_that(response.json[field], expected_value)
def should_return_error(response, status_code, expected_error):
assert_that(response.has_succeed(), is_(False))
assert_that(response.status_code, is_(status_code))
assert_that(response.json['errors'][0], is_(expected_error))
def debug_logger(request, response):
print(vars(request))
print(vars(response))
print("")