diff --git a/dandiapi/api/tests/test_robots.py b/dandiapi/api/tests/test_robots.py new file mode 100644 index 000000000..342b9754a --- /dev/null +++ b/dandiapi/api/tests/test_robots.py @@ -0,0 +1,13 @@ +import pytest +from django.urls import reverse + +@pytest.mark.django_db +def test_robots_txt(api_client): + response = api_client.get(reverse('robots_txt')) + assert response.status_code == 200 + assert response['Content-Type'] == 'text/plain' + expected_content = """ + User-agent: * + Disallow: / + """ + assert response.content.decode('utf-8').strip() == expected_content.strip() diff --git a/dandiapi/urls.py b/dandiapi/urls.py index e7364040b..c20c42a1c 100644 --- a/dandiapi/urls.py +++ b/dandiapi/urls.py @@ -81,7 +81,7 @@ def to_url(self, value): register_converter(DandisetIDConverter, 'dandiset_id') urlpatterns = [ path('', root_content_view), - path("robots.txt", robots_txt_view), + path('robots.txt', robots_txt_view), path('api/', include(router.urls)), path('api/auth/token/', auth_token_view, name='auth-token'), path('api/stats/', stats_view),