Completed
Push — master ( 3042bf...1724d9 )
by Allisson
18:05
created

test_charge_update()   A

Complexity

Conditions 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 9
rs 9.2
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
145
146
@vcr.use_cassette()
147
def test_bill_create(api, bill_data):
148
    body = bill_data
149
    response = api.bills.create(body=body)
150
    assert response.status_code == status.HTTP_201_CREATED
151
    assert response.body['bill']['id'] == bill_data['id']
152
153
154
@vcr.use_cassette()
155
def test_bill_list(api):
156
    response = api.bills.list()
157
    assert response.status_code == status.HTTP_200_OK
158
    assert 'bills' in response.body
159
160
161
@vcr.use_cassette()
162
def test_bill_retrieve(api, bill_data):
163
    response = api.bills.retrieve(bill_data['id'])
164
    assert response.status_code == status.HTTP_200_OK
165
    assert response.body['bill']['id'] == bill_data['id']
166
167
168
@vcr.use_cassette()
169
def test_bill_update(api, bill_data):
170
    body = {
171
        'code': 'first-bill'
172
    }
173
    response = api.bills.update(bill_data['id'], body=body)
174
    assert response.status_code == status.HTTP_200_OK
175
    assert response.body['bill']['id'] == bill_data['id']
176
    assert response.body['bill']['code'] == body['code']
177
178
179
@vcr.use_cassette()
180
def test_bill_destroy(api):
181
    id = 7071692
182
    response = api.bills.destroy(id)
183
    assert response.status_code == status.HTTP_200_OK
184
    assert response.body['bill']['id'] == id
185
    assert response.body['bill']['status'] == 'canceled'
186
187
188
@vcr.use_cassette()
189
def test_charge_list(api):
190
    response = api.charges.list()
191
    assert response.status_code == status.HTTP_200_OK
192
    assert 'charges' in response.body
193
194
195
@vcr.use_cassette()
196
def test_charge_retrieve(api, charge_data):
197
    response = api.charges.retrieve(charge_data['id'])
198
    assert response.status_code == status.HTTP_200_OK
199
    assert response.body['charge']['id'] == charge_data['id']
200
201
202
@vcr.use_cassette()
203
def test_charge_update(api, charge_data):
204
    body = {
205
        'installments': 2
206
    }
207
    response = api.charges.update(charge_data['id'], body=body)
208
    assert response.status_code == status.HTTP_200_OK
209
    assert response.body['charge']['id'] == charge_data['id']
210
    assert response.body['charge']['installments'] == body['installments']
211
212
213
@vcr.use_cassette()
214
def test_charge_destroy(api):
215
    id = 6814889
216
    response = api.charges.destroy(id)
217
    assert response.status_code == status.HTTP_200_OK
218
    assert response.body['charge']['id'] == id
219
    assert response.body['charge']['status'] == 'canceled'
220
221
222
@vcr.use_cassette()
223
def test_charge_charge(api, charge_data):
224
    response = api.charges.charge(charge_data['id'])
225
    assert response.status_code == status.HTTP_201_CREATED
226
    assert response.body['charge']['id'] == charge_data['id']
227
    assert response.body['charge']['status'] == 'paid'
228