Exemple #1
0
 def test_add_user_duplicate_email(self):
     """Ensure error is thrown if email already exists"""
     with self.client:
         token = login(self, active=True, admin=True)
         response = add_user_with_token(self, token, True, True)
         response = add_user_with_token(self, token, True, True)
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 400)
         self.assertIn('Sorry. That email already exists', data['message'])
         self.assertIn('fail', data['status'])
Exemple #2
0
 def test_add_user_inactive(self):
     with self.client:
         token = login(self, active=False, admin=True)
         response = add_user_with_token(self, token, True, True)
         data = json.loads(response.data.decode())
         self.assertIn(data['status'], 'fail')
         self.assertIn(data['message'], 'Provide a valid auth token.')
         self.assertEqual(response.status_code, 401)
Exemple #3
0
 def test_add_user_invalid_json(self):
     """Ensure error is thrown if JSON object is empty"""
     with self.client:
         token = login(self, active=True, admin=True)
         response = add_user_with_token(self, token, False, False)
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 400)
         self.assertIn('Invalid payload', data['message'])
         self.assertIn('fail', data['status'])
Exemple #4
0
 def test_add_user(self):
     """Ensure new client can be added to the database"""
     with self.client:
         token = login(self, active=True, admin=True)
         response = add_user_with_token(self, token, True, True)
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 201)
         self.assertIn('[email protected] was added!', data['message'])
         self.assertIn('success', data['status'])
Exemple #5
0
 def test_add_user_not_admin(self):
     with self.client:
         token = login(self, active=True, admin=False)
         response = add_user_with_token(self, token, True, True)
         data = json.loads(response.data.decode())
         self.assertIn('fail', data['status'])
         self.assertIn('You do not have permission to do that',
                       data['message'])
         self.assertEqual(response.status_code, 401)