Пример #1
0
    def test_login_api_view_incorrect_data_image(self):
        request = self.factory.post('/registration/login/api/',
                                    data=1231,
                                    format='json')
        s = SessionStore()
        s.save()
        request.session = s

        res = login_view_api(request)

        self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
Пример #2
0
    def test_login_api_view_success(self):
        login_data = {'email': self.user.email, 'password': '******'}

        request = self.factory.post('/registration/login/api/',
                                    data=login_data,
                                    format='json')
        s = SessionStore()
        s.save()
        request.session = s

        res = login_view_api(request)

        res.render()

        self.assertEqual(loads(res.content)['detail'], 'success')
        self.assertEqual(res.status_code, status.HTTP_200_OK)
Пример #3
0
    def test_login_api_view_inactive_user(self):
        login_data = {'email': self.user.email, 'password': '******'}
        self.user.is_active = False
        self.user.save()
        request = self.factory.post('/registration/login/api/',
                                    data=login_data,
                                    format='json')
        s = SessionStore()
        s.save()
        request.session = s

        res = login_view_api(request)

        res.render()

        self.assertEqual(
            loads(res.content)['detail'], 'This account has been disabled.')
        self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
Пример #4
0
    def test_login_api_view_user_does_not_exist(self):
        login_data = {
            'email': '*****@*****.**',
            'password': '******'
        }
        request = self.factory.post('/registration/login/api/',
                                    data=login_data,
                                    format='json')
        s = SessionStore()
        s.save()
        request.session = s

        res = login_view_api(request)

        res.render()

        self.assertEqual(
            loads(res.content)['detail'],
            'Incorrect password and username combination.')
        self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)