diff options
| author | 2024-04-02 15:41:11 +0100 | |
|---|---|---|
| committer | 2024-04-02 15:41:11 +0100 | |
| commit | 24f845223d723b66af3ecc832f1d47dfe20e2e23 (patch) | |
| tree | 55b55fa606b9f1d631635c217cc3090e62fb1175 /pydis_site/apps/content/tests | |
| parent | Merge pull request #1289 from python-discord/dependabot/pip/ruff-0.3.5 (diff) | |
| parent | Merge branch 'main' into upsert-tags-in-three-queries (diff) | |
Merge pull request #1287 from python-discord/upsert-tags-in-three-queries
Upsert tags in two queries
Diffstat (limited to 'pydis_site/apps/content/tests')
| -rw-r--r-- | pydis_site/apps/content/tests/test_utils.py | 12 | 
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() | 
