Created
December 30, 2022 13:27
-
-
Save rg3915/6a14e36729167d827dd9aae17a6b03f1 to your computer and use it in GitHub Desktop.
pytest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from backend.accounts.models import User | |
@pytest.fixture | |
def user(): | |
data = { | |
"first_name": "Regis", | |
"last_name": "Santos", | |
"email": "[email protected]" | |
} | |
user = User.objects.create(**data) | |
return user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[pytest] | |
DJANGO_SETTINGS_MODULE = backend.settings | |
python_files = tests.py test_*.py *_tests.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from http import HTTPStatus | |
import pytest | |
from backend.accounts.models import User | |
@pytest.mark.django_db | |
def test_user_exists(user): | |
user_exists = User.objects.filter(email=user.email) | |
assert user_exists.exists() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment