From a4ab46ffcde89236f149941d7775a8d58dc2fdcc Mon Sep 17 00:00:00 2001 From: Felix Blanke <info@fblanke.de> Date: Wed, 26 Feb 2025 17:32:15 +0100 Subject: [PATCH] Sort export lists to make dict eq test reliable --- AKModel/models.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/AKModel/models.py b/AKModel/models.py index a649fd0d..fc2157a3 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -536,8 +536,8 @@ class Event(models.Model): "blocks": [], } - rooms = Room.objects.filter(event=self) - slots = AKSlot.objects.filter(event=self) + rooms = Room.objects.filter(event=self).order_by() + slots = AKSlot.objects.filter(event=self).order_by() ak_availabilities = { ak.pk: Availability.union(ak.availabilities.all()) @@ -614,7 +614,7 @@ class Event(models.Model): "start": timeslot.avail.start.astimezone(self.timezone).strftime("%Y-%m-%d %H:%M"), "end": timeslot.avail.end.astimezone(self.timezone).strftime("%Y-%m-%d %H:%M"), }, - "fulfilled_time_constraints": time_constraints, + "fulfilled_time_constraints": sorted(time_constraints), }) timeslots["blocks"].append(current_block) @@ -1038,6 +1038,7 @@ class Room(models.Model): if not any(constr.startswith("proxy") for constr in data["fulfilled_room_constraints"]): data["fulfilled_room_constraints"].append("no-proxy") + data["fulfilled_room_constraints"].sort() return data @@ -1174,9 +1175,11 @@ class AKSlot(models.Model): "duration": math.ceil(self.duration / self.event.export_slot - ceil_offet_eps), "properties": { "conflicts": - [conflict.pk for conflict in conflict_slots.all()] - + [second_slot.pk for second_slot in other_ak_slots.all()], - "dependencies": [dep.pk for dep in dependency_slots.all()], + sorted( + [conflict.pk for conflict in conflict_slots.all()] + + [second_slot.pk for second_slot in other_ak_slots.all()] + ), + "dependencies": sorted([dep.pk for dep in dependency_slots.all()]), }, "room_constraints": [constraint.name for constraint in self.ak.requirements.all()], @@ -1206,6 +1209,9 @@ class AKSlot(models.Model): if not any(constr.startswith("proxy") for constr in data["room_constraints"]): data["room_constraints"].append("no-proxy") + data["room_constraints"].sort() + data["time_constraints"].sort() + return data class AKOrgaMessage(models.Model): -- GitLab