1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(tags): fourth audit: stale tag forms, rename after delete, stale filter

- A tags form carries the names it showed (show_hidden_initial): sent back
  unchanged, the VM's or host's tags are left as they are, so a form shown
  before a tag was renamed or deleted does not bring the old name back.
- A rename whose tag is deleted while it waits answers 404, not 500.
- A removed VM kept only for a deleted tag leaves the Removed VMs page.
- A kept tag filter the list no longer offers is forgotten, so a name made
  again later is not chosen by itself.
This commit is contained in:
catborise 2026-11-19 07:53:14 +03:00
parent 6cdaa2affd
commit 65b8110464
9 changed files with 107 additions and 12 deletions

View file

@ -95,6 +95,16 @@ class TagAdminTests(TestCase):
self.tombstone.refresh_from_db()
self.assertEqual(self.tombstone.tags, ["db"])
def test_a_tag_deleted_while_its_rename_waits_is_not_found(self):
with self.meanwhile(lambda: Tag.objects.filter(pk=self.prod.pk).delete()):
response = self.client.post(reverse("admin:tag_update", args=[self.prod.pk]), {"name": "live"})
self.assertEqual(response.status_code, 404)
def test_a_removed_vm_kept_only_for_the_deleted_tag_goes(self):
InstanceTombstone.objects.create(uuid="12345678-0000-0000-0000-00000000dd03", name="tagged-only", tags=["prod"])
self.client.post(reverse("admin:tag_delete", args=[self.prod.pk]))
self.assertEqual(list(InstanceTombstone.objects.values_list("name", flat=True)), ["gone"])
def test_a_name_taken_meanwhile_is_refused(self):
with self.meanwhile(lambda: Tag.objects.create(name="live")):
response = self.client.post(reverse("admin:tag_update", args=[self.prod.pk]), {"name": "live"})