fix more tests

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2025-06-27 18:28:13 +02:00
parent 7fcd65e318
commit 92c837f7b5
2 changed files with 9 additions and 5 deletions

View File

@ -43,11 +43,13 @@ def outpost_pre_save(sender, instance: Outpost, **_):
@receiver(m2m_changed, sender=Outpost.providers.through)
def outpost_m2m_changed(sender, instance: Provider, action: str, **_):
def outpost_m2m_changed(sender, instance: Outpost | Provider, action: str, **_):
"""Update outpost on m2m change, when providers are added or removed"""
if action in ["post_add", "post_remove", "post_clear"]:
if not isinstance(instance, OutpostModel):
return
if action not in ["post_add", "post_remove", "post_clear"]:
return
if isinstance(instance, Outpost):
outpost_send_update.send_with_options(args=(instance.pk,), rel_obj=instance)
elif isinstance(instance, OutpostModel):
for outpost in instance.outpost_set.all():
outpost_send_update.send_with_options(args=(outpost.pk,), rel_obj=outpost)
@ -66,7 +68,8 @@ def outpost_related_post_save(sender, instance: OutpostServiceConnection | Outpo
post_save.connect(outpost_related_post_save, sender=OutpostServiceConnection, weak=False)
post_save.connect(outpost_related_post_save, sender=OutpostModel, weak=False)
for subclass in OutpostModel.__subclasses__():
post_save.connect(outpost_related_post_save, sender=subclass, weak=False)
def outpost_reverse_related_post_save(sender, instance: CertificateKeyPair | Brand, **_):

View File

@ -37,6 +37,7 @@ class OutpostTests(TestCase):
# We add a provider, user should only have access to outpost and provider
outpost.providers.add(provider)
provider.refresh_from_db()
permissions = UserObjectPermission.objects.filter(user=outpost.user).order_by(
"content_type__model"
)