Completed
Push — master ( 95790f...d51337 )
by Allisson
01:14
created

tests/test_api_resources.py (2 issues)

1
import status
2
3
from tests.vcr import vcr
4
5
6 View Code Duplication
@vcr.use_cassette()
1 ignored issue
show
This code seems to be duplicated in your project.
Loading history...
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
@vcr.use_cassette()
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()
1 ignored issue
show
This code seems to be duplicated in your project.
Loading history...
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