aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/tests
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2024-04-02 19:38:06 +0100
committerGravatar GitHub <[email protected]>2024-04-02 19:38:06 +0100
commita1201ad1c73ff3b8b76432b5780232dac09d21c5 (patch)
tree762dc4c7f3d43776218a724ffbe103353ca3cfc7 /pydis_site/apps/content/tests
parentAdd test case for DRF 3.15 regression (diff)
parentMerge pull request #1287 from python-discord/upsert-tags-in-three-queries (diff)
Merge branch 'main' into add-test-case-drf-3.15-regression
Diffstat (limited to 'pydis_site/apps/content/tests')
-rw-r--r--pydis_site/apps/content/tests/test_utils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/pydis_site/apps/content/tests/test_utils.py b/pydis_site/apps/content/tests/test_utils.py
index 7f7736f9..d26c59d5 100644
--- a/pydis_site/apps/content/tests/test_utils.py
+++ b/pydis_site/apps/content/tests/test_utils.py
@@ -370,7 +370,7 @@ class TagUtilsTests(TestCase):
self.assertEqual(self.commit, models.Tag.objects.get(name=tag.name).last_commit)
@mock.patch.object(utils, "set_tag_commit")
- def test_exiting_commit(self, set_commit_mock: mock.Mock):
+ def test_existing_commit(self, set_commit_mock: mock.Mock):
"""Test that a commit is saved when the data has not changed."""
tag = models.Tag.objects.create(name="tag-name", body="old body", last_commit=self.commit)
@@ -378,8 +378,18 @@ class TagUtilsTests(TestCase):
tag.last_commit = None
utils.record_tags([tag])
+ tag.refresh_from_db()
self.assertEqual(self.commit, tag.last_commit)
result = utils.get_tag("tag-name")
self.assertEqual(tag, result)
set_commit_mock.assert_not_called()
+
+ def test_deletes_tags_no_longer_present(self):
+ """Test that no longer known tags are deleted."""
+ tag = models.Tag.objects.create(name="tag-name", body="old body", last_commit=self.commit)
+
+ utils.record_tags([])
+
+ with self.assertRaises(models.Tag.DoesNotExist):
+ tag.refresh_from_db()