Пример #1
0
 def test_create_token_invalid_credentials(self):
     """Test that token is not created if invalid credentials are given"""
     create_user(email="*****@*****.**", password="******", name="Mendo")
     payload = {'email': '*****@*****.**', 'password': '******', 'name': 'Mendo'}
     res = self.client.post(TOKEN_URL, payload)
     self.assertNotIn('token', res.data)
     self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
Пример #2
0
    def test_create_token_for_user(self):
        """Test that a token is created for the user"""
        payload = {'email': '*****@*****.**', 'password': '******', 'name': 'Mendo'}
        # creates the user successfully
        create_user(**payload)

        res = self.client.post(TOKEN_URL, {
            'email': payload['email'],
            'password': payload['password']
        })

        self.assertIn('token', res.data)
        self.assertEqual(res.status_code, status.HTTP_200_OK)
Пример #3
0
    def test_user_exists(self):
        """Test creating a user that already exists fails"""
        # Arrange
        payload = {
            'email': '*****@*****.**',
            'password': '******',
            'name': 'Mendo'
        }
        create_user(**payload)

        # Act
        res = self.client.post(CREATE_USER_URL, payload)

        # Assert
        self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
Пример #4
0
 def setUp(self):
     (self.user, self.company,
      self.company_user) = create_company(admin=create_user())
     self.client = APIClient()
     self.client.force_authenticate(user=self.user)
Пример #5
0
 def setUp(self):
     self.user = create_user()
     self.client = APIClient()
     self.client.force_authenticate(user=self.user)