def test_addOrder(self): tester = app.test_client(self) self.orders = [{'name': 'coffee'}, {'name': 'Beaf'}, {'name': 'Milk'}] self.order = {'name': 'Bread'} self.new_orders = orders.append(self.order) response = tester.post('/api/v1/all_orders', data=self.new_orders) self.assertTrue(response.status_code, 201)
def test_addOrder(self): self.client = app.test_client(self) self.orders = [{'name': 'coffee'}, {'name': 'Beaf'}, {'name': 'Milk'}] self.order = {'name': 'Bread'} self.new_orders = orders.append(self.order) self.output = self.client.post('/api/v1/all_orders', data=self.new_orders) self.assertTrue(self.output.status_code, 201)
def test_returnOne(self): self.client = app.test_client(self) self.order = "Beef" self.ords = [order for order in orders if order['name'] == self.order] return self.order self.output = self.client.get('/api/v1/all_orders/<string:name>', data=self.ords) self.assertEqual(self.output.status_code, 200)
def test_editOrder(self): tester = app.test_client(self) self.orders = [{'name': 'coffee'}, {'name': 'Beaf'}, {'name': 'Milk'}] self.order = {'name': 'Tea'} self.new_orders = [ order for order in orders if order['name'] == ['coffee'] ] self.orders[0]['name'] = self.order response = tester.put('/api/v1/all_orders', data=self.new_orders) self.assertTrue(response.status_code, 201)
def test_deleteOrder(self): tester = app.test_client(self) self.orders = [{'name': 'coffee'}, {'name': 'Beaf'}, {'name': 'Milk'}] self.new_orders = [ order for order in orders if order['name'] == ['coffee'] ] self.orders.remove(self.orders[0]) return self.new_orders response = tester.delete('/api/v1/all_orders', data=self.new_orders) self.assertTrue(response.status_code, 200) self.assertEqual(self.new_orders, [{'name': 'Beaf'}, {'name': 'Milk'}])
def test_returnAll(self): self.client = app.test_client(self) self.output = self.client.get('/api/v1/all_orders', content_type='html/text') self.assertEqual(self.output.status_code, 200)
def test_output(self): self.client = app.test_client(self) self.data = {'message': 'Itworks!'} self.output = self.client.get('/api/v1/order', data=self.data) self.assertEqual(self.output.status_code, 200)
def test_welcome(self): tester = app.test_client(self) response = tester.get('/v1', content_type='html/text') self.assertEqual(response.status_code, 200)
def test_login(self): tester = app.test_client(self) response = tester.post('/v1/login', data=dict(username="******", password="******"), follow_redirects=True) self.assertIn(b'Please Make your order', response.data)
def test_returnAll(self): tester = app.test_client(self) response = tester.get('/api/v1/all_orders', content_type='html/text') self.assertEqual(response.status_code, 200)
def test_content(self): tester = app.test_client(self) response = tester.get('/v1', content_type='html/text') self.assertTrue(b'Fast Foods Fast' in response.data)