Add a new test scenario

to trigger the implicit parent not being in the parents and ancestors lists.
This commit is contained in:
Jeff Bradberry 2024-05-29 14:42:56 -04:00
parent dbcd32a1d9
commit 2c3a7fafc5

View File

@ -0,0 +1,26 @@
from django.db import connection
from awx.main.models import InstanceGroup
InstanceGroup.objects.filter(name__in=('green', 'yellow', 'red')).delete()
green = InstanceGroup.objects.create(name='green')
red = InstanceGroup.objects.create(name='red')
yellow = InstanceGroup.objects.create(name='yellow')
for ig in InstanceGroup.objects.all():
print((ig.id, ig.name, ig.use_role_id))
with connection.cursor() as cursor:
cursor.execute("UPDATE main_instancegroup SET use_role_id = NULL WHERE name = 'red'")
cursor.execute(f"UPDATE main_instancegroup SET use_role_id = {green.use_role_id} WHERE name = 'yellow'")
green.refresh_from_db()
red.refresh_from_db()
yellow.refresh_from_db()
green.save()
red.save()
yellow.save()
print("=====================================")
for ig in InstanceGroup.objects.all():
print((ig.id, ig.name, ig.use_role_id))