Initial commit from ZIP
This commit is contained in:
commit
378d4692a9
454 files changed
+40367
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
from rest_framework import status
|
||||
from rest_framework.utils import json
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class UserLoginE2ETests:
|
||||
def test_missing_username_and_password_fail_validation(self, client):
|
||||
# Arrange
|
||||
# Act
|
||||
response = client.post(
|
||||
"/token/", data=json.dumps({}), content_type="application/json"
|
||||
)
|
||||
# Assert
|
||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||
|
||||
def test_valid_credentials_return_token(self, user_factory, client):
|
||||
# Arrange
|
||||
user_factory(username="username", password="valid_password")
|
||||
|
||||
# Act
|
||||
response = client.post(
|
||||
"/token/",
|
||||
data=json.dumps({"username": "username", "password": "valid_password"}),
|
||||
content_type="application/json",
|
||||
)
|
||||
data = response.json()
|
||||
# Assert
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert "token" in data
|
||||
Reference in new issue
Block a user