|
1 | 1 | """ |
2 | | -Regression tests for the dynamic sitemap and robots.txt (issue #1252). |
| 2 | +Regression tests for the dynamic sitemap (issue #1252). |
3 | 3 |
|
4 | | -Both endpoints are exercised through the real URL/view stack so a routing or |
5 | | -queryset regression is caught. See website/sitemaps.py and |
6 | | -website/views/robots.py. |
| 4 | +The sitemap is exercised through the real URL/view stack so a routing or |
| 5 | +queryset regression is caught. See website/sitemaps.py. |
| 6 | +
|
| 7 | +Note: robots.txt is a static file (./robots.txt) served by Apache on the |
| 8 | +servers, not a Django view, so it isn't covered here. |
7 | 9 | """ |
8 | 10 |
|
9 | | -import os |
10 | 11 | from datetime import date |
11 | | -from unittest import mock |
12 | 12 |
|
13 | 13 | from website.tests.base import DatabaseTestCase |
14 | 14 |
|
@@ -58,23 +58,3 @@ def test_sitemap_includes_news_item(self): |
58 | 58 | news = self.make_news_item(title="Big Lab News") |
59 | 59 | body = self.client.get("/sitemap.xml").content.decode() |
60 | 60 | self.assertIn(f"/news/{news.slug}/", body) |
61 | | - |
62 | | - |
63 | | -class RobotsTxtTests(DatabaseTestCase): |
64 | | - def test_robots_is_plain_text(self): |
65 | | - resp = self.client.get("/robots.txt") |
66 | | - self.assertEqual(resp.status_code, 200) |
67 | | - self.assertEqual(resp["Content-Type"], "text/plain") |
68 | | - |
69 | | - @mock.patch.dict(os.environ, {"DJANGO_ENV": "PROD"}) |
70 | | - def test_robots_prod_allows_and_advertises_sitemap(self): |
71 | | - body = self.client.get("/robots.txt").content.decode() |
72 | | - self.assertIn("Allow: /", body) |
73 | | - self.assertIn("Sitemap:", body) |
74 | | - self.assertIn("/sitemap.xml", body) |
75 | | - |
76 | | - @mock.patch.dict(os.environ, {"DJANGO_ENV": "TEST"}) |
77 | | - def test_robots_non_prod_disallows_all(self): |
78 | | - body = self.client.get("/robots.txt").content.decode() |
79 | | - self.assertIn("Disallow: /", body) |
80 | | - self.assertNotIn("Allow: /", body) |
0 commit comments