Skip to content

🍰 Tests - #5

Open
Olderestin wants to merge 7 commits into
devfrom
feature/tests
Open

🍰 Tests#5
Olderestin wants to merge 7 commits into
devfrom
feature/tests

Conversation

@Olderestin

Copy link
Copy Markdown
Owner

What changed?

Create tests for API endpoints using pytest.

Checklist before requesting a review

  • I have performed a self-review of my code
  • Code is functional on my machine(Windows 10/Debian GNU/Linux 11 (bullseye))

@memhard memhard left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need changes!

Comment thread pytest.ini Outdated
[pytest]
DJANGO_SETTINGS_MODULE = app.settings
# -- recommended but optional:
python_files = tests.py test_*.py *_tests.py No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment that

Comment thread team/tests/fixtures.py Outdated
import pytest
from rest_framework.test import APIClient

@pytest.fixture

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider to rename fixtures.py -> conftest.py

Comment thread team/tests/test_data.py Outdated
@@ -0,0 +1,20 @@

def create_member_data():

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where annotations? make some dataclasses for that

Comment thread team/tests/test_data.py Outdated

return data

def create_team_data():

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where annotations? make some dataclasses for that

Comment thread team/tests/team_tests.py Outdated
#positive case
@pytest.mark.parametrize("data", DATA)
@pytest.mark.django_db
def test_create_team(client: client, data: dict) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data - bad annotation

Comment thread team/tests/member_tests.py Outdated

@pytest.mark.parametrize("data", DATA)
@pytest.mark.django_db
def test_delete_member(client: client, data: dict) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data - bad annotation

Comment thread team/tests/member_tests.py Outdated
#negative case
@pytest.mark.parametrize("data", DATA)
@pytest.mark.django_db
def test_create_member_missing_required_fields(client: client, data: dict) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data - bad annotation

assert not Member.objects.exists()

@pytest.mark.django_db
def test_get_nonexistent_member_detail(client: client) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data - bad annotation

Comment thread team/tests/member_tests.py Outdated

@pytest.mark.parametrize("data", DATA)
@pytest.mark.django_db
def test_update_nonexistent_member(client: client, data: dict) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data - bad annotation

Comment thread config.py
"""
Class for storing app settings.
"""
model_config = SettingsConfigDict(env_file='.env', case_sensitive=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need SettingsConfigDict?

@Olderestin Olderestin left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes done.

@memhard memhard left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Comment thread pytest.ini Outdated
[pytest]
DJANGO_SETTINGS_MODULE = app.settings
# -- recommended but optional:
python_files = '''tests.py test_*.py''' *_tests.py No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move comment to another place

@memhard memhard left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants