Fix typo
This commit is contained in:
1
core/apps/api/tests/search/__init__.py
Normal file
1
core/apps/api/tests/search/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .test_search_history import * # noqa
|
||||
56
core/apps/api/tests/search/test_search_history.py
Normal file
56
core/apps/api/tests/search/test_search_history.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import pytest
|
||||
from django.urls import reverse
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from core.apps.accounts.models import SearchHistory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def instance(db):
|
||||
return SearchHistory._baker()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def api_client(instance):
|
||||
client = APIClient()
|
||||
client.force_authenticate(user=instance.user)
|
||||
return client, instance
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def data(api_client):
|
||||
client, instance = api_client
|
||||
return (
|
||||
{
|
||||
"list": reverse("search-history-list"),
|
||||
"retrieve": reverse("search-history-detail", kwargs={"pk": instance.pk}),
|
||||
"retrieve-not-found": reverse("search-history-detail", kwargs={"pk": 1000}),
|
||||
},
|
||||
client,
|
||||
instance,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_list(data):
|
||||
urls, client, _ = data
|
||||
response = client.get(urls["list"])
|
||||
data_resp = response.json()
|
||||
assert response.status_code == 200
|
||||
assert data_resp["status"] is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_create(data):
|
||||
urls, client, _ = data
|
||||
response = client.post(urls["list"], data={"value": "test-text"})
|
||||
data_resp = response.json()
|
||||
assert response.status_code == 201
|
||||
assert data_resp["status"] is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_destroy(data):
|
||||
urls, client, _ = data
|
||||
response = client.delete(urls["retrieve"])
|
||||
assert response.status_code == 204
|
||||
Reference in New Issue
Block a user