Completed
Push — master ( e3afa2...0f6934 )
by Allisson
01:45
created

test_payment_profiles_retrieve()   A

Complexity

Conditions 3

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
1
import status
2
3
from tests.vcr import vcr
4
5
6 View Code Duplication
@vcr.use_cassette()
7
def test_customer_create(api, customer_data):
8
    body = {
9
        'name': customer_data['customer']['name'],
10
        'email': customer_data['customer']['email']
11
    }
12
    response = api.customers.create(body=body)
13
    assert response.status_code == status.HTTP_201_CREATED
14
    assert response.body['customer']['id'] == customer_data['customer']['id']
15
16
17
@vcr.use_cassette()
18
def test_customer_list(api):
19
    response = api.customers.list()
20
    assert response.status_code == status.HTTP_200_OK
21
    assert 'customers' in response.body
22
23
24
@vcr.use_cassette()
25
def test_customer_retrieve(api, customer_data):
26
    response = api.customers.retrieve(customer_data['customer']['id'])
27
    assert response.status_code == status.HTTP_200_OK
28
    assert response.body['customer']['id'] == customer_data['customer']['id']
29
30
31 View Code Duplication
@vcr.use_cassette()
0 ignored issues
show
Duplication introduced by Allisson Azevedo
This code seems to be duplicated in your project.
Loading history...
32
def test_customer_update(api, customer_data):
33
    body = {
34
        'name': 'Jane Doe',
35
        'email': '[email protected]'
36
    }
37
    response = api.customers.update(customer_data['customer']['id'], body=body)
38
    assert response.status_code == status.HTTP_200_OK
39
    assert response.body['customer']['id'] == customer_data['customer']['id']
40
    assert response.body['customer']['name'] == body['name']
41
    assert response.body['customer']['email'] == body['email']
42
43
44 View Code Duplication
@vcr.use_cassette()
45
def test_customer_destroy(api, customer_data):
46
    response = api.customers.destroy(customer_data['customer']['id'])
47
    assert response.status_code == status.HTTP_200_OK
48
    assert response.body['customer']['id'] == customer_data['customer']['id']
49
    assert response.body['customer']['status'] == 'archived'
50
51
52
@vcr.use_cassette()
53
def test_product_create(api, product_data):
54
    body = {
55
        'name': product_data['product']['name'],
56
        'code': product_data['product']['code'],
57
        'status': product_data['product']['status'],
58
        'pricing_schema': {
59
            'price': product_data['product']['pricing_schema']['price'],
60
            'schema_type': product_data['product']['pricing_schema']['schema_type'],
61
        }
62
    }
63
    response = api.products.create(body=body)
64
    assert response.status_code == status.HTTP_201_CREATED
65
    assert response.body['product']['id'] == product_data['product']['id']
66
67
68
@vcr.use_cassette()
69
def test_product_list(api):
70
    response = api.products.list()
71
    assert response.status_code == status.HTTP_200_OK
72
    assert 'products' in response.body
73
74
75
@vcr.use_cassette()
76
def test_product_retrieve(api, product_data):
77
    response = api.products.retrieve(product_data['product']['id'])
78
    assert response.status_code == status.HTTP_200_OK
79
    assert response.body['product']['id'] == product_data['product']['id']
80
81
82 View Code Duplication
@vcr.use_cassette()
0 ignored issues
show
Duplication introduced by Allisson Azevedo
This code seems to be duplicated in your project.
Loading history...
83
def test_product_update(api, product_data):
84
    body = {
85
        'name': 'Product 1',
86
        'code': 'product-1',
87
    }
88
    response = api.products.update(product_data['product']['id'], body=body)
89
    assert response.status_code == status.HTTP_200_OK
90
    assert response.body['product']['id'] == product_data['product']['id']
91
    assert response.body['product']['name'] == body['name']
92
    assert response.body['product']['code'] == body['code']
93
94
95
@vcr.use_cassette()
96
def test_payment_methods_list(api):
97
    response = api.payment_methods.list()
98
    assert response.status_code == status.HTTP_200_OK
99
    assert 'payment_methods' in response.body
100
101
102
@vcr.use_cassette()
103
def test_payment_methods_retrieve(api, payment_method_data):
104
    response = api.payment_methods.retrieve(payment_method_data['payment_method']['id'])
105
    assert response.status_code == status.HTTP_200_OK
106
    assert response.body['payment_method']['id'] == payment_method_data['payment_method']['id']
107
108
109
@vcr.use_cassette()
110
def test_payment_profiles_create(api, payment_profile_data):
111
    body = payment_profile_data
112
    response = api.payment_profiles.create(body=body)
113
    assert response.status_code == status.HTTP_201_CREATED
114
    assert response.body['payment_profile']['id'] == payment_profile_data['id']
115
116
117
@vcr.use_cassette()
118
def test_payment_profiles_list(api):
119
    response = api.payment_profiles.list()
120
    assert response.status_code == status.HTTP_200_OK
121
    assert 'payment_profiles' in response.body
122
123
124
@vcr.use_cassette()
125
def test_payment_profiles_retrieve(api, payment_profile_data):
126
    response = api.payment_profiles.retrieve(payment_profile_data['id'])
127
    assert response.status_code == status.HTTP_200_OK
128
    assert response.body['payment_profile']['id'] == payment_profile_data['id']
129
130
131
@vcr.use_cassette()
132
def test_payment_profiles_verify(api, payment_profile_data):
133
    response = api.payment_profiles.verify(payment_profile_data['id'])
134
    assert response.status_code == status.HTTP_201_CREATED
135
    assert 'transaction' in response.body
136
137
138
@vcr.use_cassette()
139
def test_payment_profiles_destroy(api, payment_profile_data):
140
    response = api.payment_profiles.destroy(payment_profile_data['id'])
141
    assert response.status_code == status.HTTP_200_OK
142
    assert response.body['payment_profile']['id'] == payment_profile_data['id']
143
    assert response.body['payment_profile']['status'] == 'inactive'
144