def setUp(self): self.app_factory = self.create_app() self.app = self.app_factory.test_client() fixtures(self.db_name, "store", "store/fixtures/stores") fixtures(self.db_name, "customer", "customer/fixtures/customers") data = { "app_id": "my_furniture_app", "app_secret": "my_furniture_secret" } rv = self.app.post('/store/token/', data=json.dumps(data), content_type='application/json') token = json.loads(rv.data.decode('utf-8')).get("token") self.headers = { "APP-ID": "my_furniture_app", "ACCESS-TOKEN": token } data = { "app_id": "my_dog_app", "app_secret": "my_dog_secret" } rv = self.app.post('/store/token/', data=json.dumps(data), content_type='application/json') token = json.loads(rv.data.decode('utf-8')).get("token") self.other_store_headers = { "APP-ID": "my_dog_app", "ACCESS-TOKEN": token }
def test_pagination(self): # get app up and running self.create_api_app() self.generate_access_token() # import fixtures fixtures(self.db_name, "store", "store/fixtures/stores.json") fixtures(self.db_name, "pet", "pet/fixtures/pets.json") # get all stores rv = self.app.get('/pets/', headers=self.headers(), content_type='application/json') assert "next" in str(rv.data) # get second page of stores rv = self.app.get('/pets/?page=2', headers=self.headers(), content_type='application/json') assert "previous" in str(rv.data)
def test_pagination(self): # get app up and running self.create_api_app() self.generate_access_token() # import fixtures # uploaded test recs to db fixtures(self.db_name, "appts", "appt/fixtures/appts.json") # get all appts rcode = self.app.get('/appts/', headers=self.headers(), content_type='application/json') assert "next" in str(rcode.data) # get second page of appts rcode = self.app.get('/appts/?page=2', headers=self.headers(), content_type='application/json') assert "previous" in str(rcode.data) assert "next" in str(rcode.data)
def setUp(self): self.app_factory = self.create_app() self.app = self.app_factory.test_client() fixtures(self.db_name, "store", "store/fixtures/stores") fixtures(self.db_name, "customer", "customer/fixtures/customers") fixtures(self.db_name, "product", "product/fixtures/products.json") fixtures(self.db_name, "cart", "cart/fixtures/cart") fixtures(self.db_name, "cart_item", "cart/fixtures/cart_items") fixtures(self.db_name, "gift_card", "gift_card/fixtures/gift_cards") fixtures(self.db_name, "credit", "credit/fixtures/credits") fixtures(self.db_name, "invoice", "invoice/fixtures/invoices") fixtures(self.db_name, "invoice_line_item", "invoice/fixtures/invoice_line_items") fixtures(self.db_name, "order", "orders/fixtures/orders") data = { "app_id": "my_furniture_app", "app_secret": "my_furniture_secret" } rv = self.app.post('/store/token/', data=json.dumps(data), content_type='application/json') token = json.loads(rv.data.decode('utf-8')).get("token") self.headers = { "APP-ID": "my_furniture_app", "ACCESS-TOKEN": token } data = { "app_id": "my_dog_app", "app_secret": "my_dog_secret" } rv = self.app.post('/store/token/', data=json.dumps(data), content_type='application/json') token = json.loads(rv.data.decode('utf-8')).get("token") self.other_store_headers = { "APP-ID": "my_dog_app", "ACCESS-TOKEN": token } self.incorrect_headers = { "APP-ID": "my_furniture_app", "ACCESS-TOKEN": "INCORRECT_TOKEN" }