Exemplo n.º 1
0
 def test_delete(self):
     '''
     Test: delete record (facebookId=4)
     '''
     tester = app.test_client(self)
     response = tester.delete('/person/4')
     self.assertEqual(response.status_code, 204)
Exemplo n.º 2
0
 def test_get_limit(self):
     '''
     Test: get all records if args is misstyped (limits)
     '''
     tester = app.test_client(self)
     response = tester.get('/person?limits=1')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), P1P2)
Exemplo n.º 3
0
 def test_get_one(self):
     '''
     Test: get limit of 1 record 
     '''
     tester = app.test_client(self)
     response = tester.get('/person?limit=1')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), P1)
Exemplo n.º 4
0
 def test_get_none(self):
     '''
     Test: get limit of 0 records
     '''
     tester = app.test_client(self)
     response = tester.get('/person?limit=0')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), {'persons': []})
Exemplo n.º 5
0
 def test_get(self):
     '''
     Test: get all records
     '''
     tester = app.test_client(self)
     response = tester.get('/person')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), P1P2)
Exemplo n.º 6
0
 def test_delete_inexist(self):
     '''
     Test: delete record that doesn't exist (facebookId=40)
     '''
     tester = app.test_client(self)
     response = tester.delete('/person/40')
     self.assertEqual(response.status_code, 404)
     self.assertEqual(json.loads(response.data), {'error': 'Not found.'})
Exemplo n.º 7
0
 def test_post_mistyped(self):
     '''
     Test: post new record with mistyped fields (FACEBOOKID=40)
     '''
     tester = app.test_client(self)
     response = tester.post('/person', data=dict(FACEBOOKID=40))
     self.assertEqual(response.status_code, 400)
     self.assertEqual(json.loads(response.data), {'error': 'Bad request.'})
Exemplo n.º 8
0
 def test_post(self):
     '''
     Test: post new record (facebookId=40)
     '''
     tester = app.test_client(self)
     response = tester.post('/person', data=dict(facebookId=40))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), P3)
Exemplo n.º 9
0
 def test_get_unknown(self):
     '''
     Test: get record from unknown (facebookId=0)
     '''
     tester = app.test_client(self)
     response = tester.get('/person/0')
     self.assertEqual(response.status_code, 404)
     self.assertEqual(json.loads(response.data), {'error': 'Not found.'})
Exemplo n.º 10
0
 def test_get_mark(self):
     '''
     Test: get record from mark (facebookId=4)
     '''
     tester = app.test_client(self)
     response = tester.get('/person/4')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), P1)
Exemplo n.º 11
0
 def test_post_inexist(self):
     '''
     Test: post new record that doesn't exist on Facebook (facebookId=0)
     '''
     tester = app.test_client(self)
     response = tester.post('/person', data=dict(facebookId=0))
     self.assertEqual(response.status_code, 803)
     self.assertEqual(json.loads(response.data),
                      {'error': 'The alias you requested do not exist.'})