🍰 Tests - #5
Open
Olderestin wants to merge 7 commits into
Open
Conversation
memhard
suggested changes
Feb 23, 2024
| [pytest] | ||
| DJANGO_SETTINGS_MODULE = app.settings | ||
| # -- recommended but optional: | ||
| python_files = tests.py test_*.py *_tests.py No newline at end of file |
| import pytest | ||
| from rest_framework.test import APIClient | ||
|
|
||
| @pytest.fixture |
There was a problem hiding this comment.
consider to rename fixtures.py -> conftest.py
| @@ -0,0 +1,20 @@ | |||
|
|
|||
| def create_member_data(): | |||
There was a problem hiding this comment.
where annotations? make some dataclasses for that
|
|
||
| return data | ||
|
|
||
| def create_team_data(): |
There was a problem hiding this comment.
where annotations? make some dataclasses for that
| #positive case | ||
| @pytest.mark.parametrize("data", DATA) | ||
| @pytest.mark.django_db | ||
| def test_create_team(client: client, data: dict) -> None: |
|
|
||
| @pytest.mark.parametrize("data", DATA) | ||
| @pytest.mark.django_db | ||
| def test_delete_member(client: client, data: dict) -> None: |
| #negative case | ||
| @pytest.mark.parametrize("data", DATA) | ||
| @pytest.mark.django_db | ||
| def test_create_member_missing_required_fields(client: client, data: dict) -> None: |
| assert not Member.objects.exists() | ||
|
|
||
| @pytest.mark.django_db | ||
| def test_get_nonexistent_member_detail(client: client) -> None: |
|
|
||
| @pytest.mark.parametrize("data", DATA) | ||
| @pytest.mark.django_db | ||
| def test_update_nonexistent_member(client: client, data: dict) -> None: |
| """ | ||
| Class for storing app settings. | ||
| """ | ||
| model_config = SettingsConfigDict(env_file='.env', case_sensitive=True) |
memhard
approved these changes
Feb 23, 2024
| [pytest] | ||
| DJANGO_SETTINGS_MODULE = app.settings | ||
| # -- recommended but optional: | ||
| python_files = '''tests.py test_*.py''' *_tests.py No newline at end of file |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
Create tests for API endpoints using pytest.
Checklist before requesting a review