Skip to content

Commit

Permalink
tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Oct 8, 2024
1 parent b18fed2 commit 88b9c51
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions peachjam/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.test import TestCase

from peachjam.models import PeachJamSettings


class PeachjamViewsTest(TestCase):
fixtures = ["tests/countries", "documents/sample_documents"]
Expand Down Expand Up @@ -177,3 +179,22 @@ def test_generic_document_detail(self):
"/akn/aa-au/doc/activity-report/2017/nn/eng@2017-07-03",
)
self.assertTrue(hasattr(response.context["document"], "authors"))

def test_robots_txt(self):
response = self.client.get("/robots.txt")
self.assertEqual(response.status_code, 200)
self.assertContains(response, "User-agent")

settings = PeachJamSettings.load()
settings.robots_txt = None
settings.save()

response = self.client.get("/robots.txt")
self.assertContains(response, "User-agent")
self.assertNotContains(response, "None")

settings.robots_txt = "foo\nbar"
settings.save()

response = self.client.get("/robots.txt")
self.assertContains(response, "foo\nbar")

0 comments on commit 88b9c51

Please sign in to comment.