-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(profiles, randoms, recommendations, reviews): create new folder …
…structure and update integration tests
- Loading branch information
1 parent
390e8a6
commit 629383b
Showing
14 changed files
with
129 additions
and
91 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Endpoints Tests for Profiles App.""" | ||
|
||
import pytest | ||
from rest_framework import status | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_list_profiles(administrator_user, profile): | ||
endpoint = "/api/v1/profiles/" | ||
response = administrator_user.get(endpoint) | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.reason_phrase == "OK" | ||
assert len(response.data["results"]) == 1 | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_list_profiles_errors(member_user, profile): | ||
endpoint = "/api/v1/profiles/" | ||
member_response = member_user.get(endpoint) | ||
assert member_response.status_code == status.HTTP_403_FORBIDDEN | ||
assert member_response.reason_phrase == "Forbidden" | ||
member_user.logout() | ||
anonymus_response = member_user.get(endpoint) | ||
assert anonymus_response.status_code == status.HTTP_401_UNAUTHORIZED | ||
assert anonymus_response.reason_phrase == "Unauthorized" | ||
|
||
|
||
# TODO: Add action tests |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Model Tests for Profiles App.""" |
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
"""Endpoint Tests for Randoms App.""" | ||
|
||
import pytest | ||
from rest_framework import status | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrive_random_anime(anonymous_user, anime): | ||
endpoint = "/api/v1/random/anime/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.reason_phrase == "OK" | ||
assert len(response.data) > 0 | ||
assert response.data["name"] == anime.name | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrive_random_anime_errors(anonymous_user): | ||
endpoint = "/api/v1/random/anime/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_404_NOT_FOUND | ||
assert response.reason_phrase == "Not Found" | ||
assert response.data["detail"] == "No available content found." | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrieve_random_manga(anonymous_user, manga): | ||
endpoint = "/api/v1/random/manga/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.reason_phrase == "OK" | ||
assert len(response.data) > 0 | ||
assert response.data["name"] == manga.name | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrieve_random_manga_errors(anonymous_user): | ||
endpoint = "/api/v1/random/manga/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_404_NOT_FOUND | ||
assert response.reason_phrase == "Not Found" | ||
assert response.data["detail"] == "No available content found." | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrieve_random_character(anonymous_user, character): | ||
endpoint = "/api/v1/random/character/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.reason_phrase == "OK" | ||
assert len(response.data) > 0 | ||
assert response.data["name"] == character.name | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrieve_random_character_errors(anonymous_user): | ||
endpoint = "/api/v1/random/character/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_404_NOT_FOUND | ||
assert response.reason_phrase == "Not Found" | ||
assert response.data["detail"] == "No available content found." | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrieve_random_person(anonymous_user, person): | ||
endpoint = "/api/v1/random/person/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.reason_phrase == "OK" | ||
assert len(response.data) > 0 | ||
assert response.data["name"] == person.name | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_retrieve_random_person_errors(anonymous_user): | ||
endpoint = "/api/v1/random/person/" | ||
response = anonymous_user.get(endpoint) | ||
assert response.status_code == status.HTTP_404_NOT_FOUND | ||
assert response.reason_phrase == "Not Found" | ||
assert response.data["detail"] == "No available content found." |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Model Test for Reviews App.""" |
This file contains 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