Example #1
0
 def test_store_read(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     rq = client.get('/api/stores/' + store,
                     headers={
                         'X-APP-ID': 'pet_client',
                         'X-APP-TOKEN': token,
                     })
     assert json.loads(
         rq.data.decode('utf-8'))['store']['phone'] == '425-894-1012'
Example #2
0
 def test_delete(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     rq = client.delete('/api/stores/' + store,
                        headers={
                            'X-APP-ID': 'pet_client',
                            'X-APP-TOKEN': token,
                        })
     assert rq.status_code == 204
     assert Store.objects.filter(live=False).count() == 1
Example #3
0
 def test_pet_delete(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     pet = help_create_pet(client, store, token)
     rv = client.delete('/api/pets/' + pet,
                        content_type='application/json',
                        headers={
                            'X-APP-ID': 'pet_client',
                            'X-APP-TOKEN': token,
                        })
     assert rv.status_code == 204
     assert Pet.objects.filter(live=False).count() == 1
Example #4
0
 def test_pet_read(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     pet = help_create_pet(client, store, token)
     rv = client.get('/api/pets/' + pet,
                     content_type='application/json',
                     headers={
                         'X-APP-ID': 'pet_client',
                         'X-APP-TOKEN': token,
                     })
     assert rv.status_code == 200
     assert json.loads(rv.data.decode('utf-8'))['pet']['name'] == 'Mac'
Example #5
0
 def test_pagination(self, client):
     help_import_test_data('store', 'data/stores.json')
     help_create_app(client)
     token = help_create_token(client)
     rq = client.get('/api/stores/',
                     headers={
                         'X-APP-ID': 'pet_client',
                         'X-APP-TOKEN': token,
                     })
     assert 'next' in str(rq.data)
     rq = client.get('/api/stores/?page=2',
                     headers={
                         'X-APP-ID': 'pet_client',
                         'X-APP-TOKEN': token,
                     })
     assert 'previous' in str(rq.data)
     assert 'next' in str(rq.data)
Example #6
0
 def test_update(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     raw_payload = {
         "neighborhood": "Shannonwood",
         "street_adress": "1708 211th Pl NE",
         "city": "Sammamish",
         "state": "CA",
         "zip": "98074",
         "phone": "425-894-1012"
     }
     rq = client.put('/api/stores/' + store,
                     data=json.dumps(raw_payload),
                     content_type='application/json',
                     headers={
                         'X-APP-ID': 'pet_client',
                         'X-APP-TOKEN': token,
                     })
     assert rq.status_code == 200
     assert json.loads(rq.data.decode('utf-8'))['store']['state'] == 'CA'
Example #7
0
 def test_pet_update(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     pet = help_create_pet(client, store, token)
     raw_payload = {
         'name': 'Lala',
         'species': 'dog',
         'breed': 'ShiTzu',
         'age': 11,
         'store': store,
         'price': '855.22',
         'received_date': '2018-02-28T12:00:00Z'
     }
     rv = client.put('/api/pets/' + pet,
                     data=json.dumps(raw_payload),
                     content_type='application/json',
                     headers={
                         'X-APP-ID': 'pet_client',
                         'X-APP-TOKEN': token,
                     })
     assert rv.status_code == 200
     assert json.loads(rv.data.decode('utf-8'))['pet']['name'] == 'Lala'
Example #8
0
 def test_store_create(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     assert store
Example #9
0
 def test_pet_create(self, client):
     help_create_app(client)
     token = help_create_token(client)
     store = help_create_store(client, token)
     pet = help_create_pet(client, store, token)
     assert pet