develop #4

Merged
s460930 merged 29 commits from develop into master 2020-12-07 15:22:26 +01:00
3 changed files with 21 additions and 3 deletions
Showing only changes of commit 1c6089b674 - Show all commits

View File

View File

@ -1,3 +1,21 @@
from django.test import TestCase from rest_framework.test import APITestCase, APIClient
from django.urls import reverse
from smartpicasso.app.user.models import User
from rest_framework import status
# Create your tests here.
class UserApiTest(APITestCase):
client = APIClient()
def test_login_when_user_non_exist(self):
url = reverse('authenticate')
response = self.client.post(url, {'email': 'non-exist', 'password': '123'}, format='json')
assert response.status_code == 400
def test_login_when_user_exist(self):
User.objects.create_user(email='test@test.com', password='test')
url = reverse('authenticate')
response = self.client.post(url, {'email': 'test@test.com', 'password': 'test'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['success'], 'True')
self.assertIn('token', response.data)

View File

@ -7,5 +7,5 @@ from django.conf.urls import url
from smartpicasso.app.user.views import UserLoginView from smartpicasso.app.user.views import UserLoginView
urlpatterns = [ urlpatterns = [
url(r'^authenticate', UserLoginView.as_view()) url(r'^authenticate', UserLoginView.as_view(), name='authenticate')
] ]