23 lines
624 B
Python
23 lines
624 B
Python
from http import HTTPStatus
|
|
|
|
import pytest
|
|
from django.urls import reverse
|
|
|
|
|
|
def test_swagger_accessible_by_admin(admin_client):
|
|
url = reverse("api-docs")
|
|
response = admin_client.get(url)
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_swagger_ui_not_accessible_by_normal_user(client):
|
|
url = reverse("api-docs")
|
|
response = client.get(url)
|
|
assert response.status_code == HTTPStatus.FORBIDDEN
|
|
|
|
|
|
def test_api_schema_generated_successfully(admin_client):
|
|
url = reverse("api-schema")
|
|
response = admin_client.get(url)
|
|
assert response.status_code == HTTPStatus.OK
|