Skip to content

Commit da9c20d

Browse files
committed
tests: add them
1 parent 6eb16d2 commit da9c20d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

downloads/tests/test_views.py

+43
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,46 @@ def test_filter_release_file_delete_by_release(self):
554554
headers={"authorization": self.Authorization}
555555
)
556556
self.assertEqual(response.status_code, 405)
557+
558+
class ReleaseFeedTests(BaseDownloadTests):
559+
"""Tests for the downloads/feed.rss endpoint.
560+
561+
Content is ensured via setUp in BaseDownloadTests.
562+
"""
563+
564+
def setUp(self) -> None:
565+
super().setUp()
566+
self.url = reverse("downloads:feed")
567+
568+
def test_endpoint_reachable(self) -> None:
569+
response = self.client.get(self.url)
570+
self.assertEqual(response.status_code, 200)
571+
572+
def test_feed_content(self) -> None:
573+
"""Ensure feed content is as expected.
574+
575+
Some things we want to check:
576+
- Feed title, description, pubdate
577+
- Feed items (releases) are in the correct order
578+
- We get the expected number of releases (10)
579+
"""
580+
response = self.client.get(self.url)
581+
content = response.content.decode()
582+
583+
self.assertIn("Python 2.7.5", content)
584+
self.assertIn("Python 3.10", content)
585+
# Published but hidden show up in the API and thus the feed
586+
self.assertIn("Python 0.0.0", content)
587+
588+
# No unpublished releases
589+
self.assertNotIn("Python 9.7.2", content)
590+
591+
# Pre-releases are shown
592+
self.assertIn("Python 3.9.90", content)
593+
594+
def test_feed_item_count(self) -> None:
595+
response = self.client.get(self.url)
596+
content = response.content.decode()
597+
598+
# In BaseDownloadTests, we create 5 releases, 4 of which are published, 1 of those published are hidden..
599+
self.assertEqual(content.count("<item>"), 4)

0 commit comments

Comments
 (0)