Example #1
0
 def test_invalid_call(self):
     data = {'dividend': "a", 'divisor': 2}
     response = self.client.post(self.divide_url, data)
     self.assertEqual(response.status_code, 400)
     response_data = json.loads(smart_u(response.content))
     dividend_error = response_data['errors']['dividend']
     self.assertEqual(dividend_error[0], smart_u(IntegerField().error_messages['invalid']))
     self.assertGreater(len(response_data['errors']), 0)
     self.assertFalse(response_data['success'])
     self.assertFalse(response_data['data'])
Example #2
0
 def test_invalid_call(self):
     data = {'dividend': "a", 'divisor': 2}
     response = self.client.post(self.divide_url, data)
     self.assertEqual(response.status_code, 400)
     response_data = json.loads(smart_u(response.content))
     dividend_error = response_data['errors']['dividend']
     self.assertEqual(dividend_error[0],
                      smart_u(IntegerField().error_messages['invalid']))
     self.assertGreater(len(response_data['errors']), 0)
     self.assertFalse(response_data['success'])
     self.assertFalse(response_data['data'])
Example #3
0
 def test_valid_auth(self):
     response = self.send_request(self.authenticate_url, {'username': self.user.username, 'password': '******'})
     self.assertEqual(response.status_code, 200)
     response_data = json.loads(smart_u(response.content))
     self.assertEqual(response_data['errors'], {})
     self.assertTrue(response_data['success'])
     self.assertIsNotNone(response_data['data'])
Example #4
0
 def test_invalid_password(self):
     data = {'username': self.user.username, 'password': '******'}
     response = self.send_request(self.authenticate_url, data)
     self.assertEqual(response.status_code, 400)
     response_data = json.loads(smart_u(response.content))
     self.assertGreater(len(response_data['errors']), 0)
     self.assertFalse(response_data['success'])
     self.assertFalse(response_data['data'])
Example #5
0
 def test_invalid_password(self):
     data = {'username': self.user.username, 'password': '******'}
     response = self.send_request(self.authenticate_url, data)
     self.assertEqual(response.status_code, 400)
     print(repr(response.content))
     response_data = json.loads(smart_u(response.content))
     self.assertGreater(len(response_data['errors']), 0)
     self.assertFalse(response_data['success'])
     self.assertFalse(response_data['data'])
Example #6
0
 def test_valid_auth(self):
     response = self.send_request(self.authenticate_url, {
         'username': self.user.username,
         'password': '******'
     })
     self.assertEqual(response.status_code, 200)
     response_data = json.loads(smart_u(response.content))
     self.assertEqual(response_data['errors'], {})
     self.assertTrue(response_data['success'])
     self.assertIsNotNone(response_data['data'])
Example #7
0
 def test_api_key(self):
     smart_u(self.api_key)
Example #8
0
 def test_error_call(self):
     data = {'dividend': "42", 'divisor': 0}
     response = self.client.post(self.divide_url, data)
     response_data = json.loads(smart_u(response.content))
     self.assertFalse(response_data['success'])
Example #9
0
 def test_ok_call(self):
     data = {'dividend': 7, 'divisor': 2}
     response = self.client.post(self.divide_url, data)
     self.assertEqual(response.status_code, 200)
     response_data = json.loads(smart_u(response.content))
     self.assertEqual(response_data['data'], 3.5)
Example #10
0
 def test_api_key(self):
     smart_u(self.api_key)
Example #11
0
 def test_error_call(self):
     data = {'dividend': "42", 'divisor': 0}
     response = self.client.post(self.divide_url, data)
     response_data = json.loads(smart_u(response.content))
     self.assertFalse(response_data['success'])
Example #12
0
 def test_ok_call(self):
     data = {'dividend': 7, 'divisor': 2}
     response = self.client.post(self.divide_url, data)
     self.assertEqual(response.status_code, 200)
     response_data = json.loads(smart_u(response.content))
     self.assertEqual(response_data['data'], 3.5)