@@ -1069,6 +1069,58 @@ def test__query_reservation_unit_reservable__reservations__in_common_hierarchy__
10691069 }
10701070
10711071
1072+ @freezegun .freeze_time (NOW )
1073+ def test__query_reservation_unit_reservable__reservations__in_common_hierarchy__by_resource__additional_filters (
1074+ graphql , reservation_unit
1075+ ):
1076+ """
1077+ This is a regression test for a bug that was found during manual testing.
1078+ Simply recreate the exact scenario instead of using the above test cases.
1079+
1080+ The error occurred when the ReservationUnit GQL query had additional filters that filtered out ReservationUnits
1081+ which were related in common hierarchy by Resource and had a Space which was not related in common hierarcy.
1082+ """
1083+ common_resource = ResourceFactory ()
1084+ reservation_unit_2 : ReservationUnit = ReservationUnitFactory .create (
1085+ resources = [common_resource ],
1086+ spaces = [SpaceFactory ()],
1087+ origin_hauki_resource = reservation_unit .origin_hauki_resource ,
1088+ )
1089+ reservation_unit .resources .set ([common_resource ])
1090+ reservation_unit .spaces .set ([SpaceFactory ()])
1091+ reservation_unit .save ()
1092+
1093+ # 2023-05-20 10:00 - 12:00 (2h)
1094+ ReservationFactory .create (
1095+ begin = _datetime (day = 20 , hour = 10 ),
1096+ end = _datetime (day = 20 , hour = 12 ),
1097+ reservation_unit = [reservation_unit_2 ],
1098+ state = ReservationStateChoice .CREATED ,
1099+ )
1100+
1101+ # 2023-05-20 10:00 - 12:00 (2h)
1102+ ReservableTimeSpanFactory .create (
1103+ resource = reservation_unit .origin_hauki_resource ,
1104+ start_datetime = _datetime (day = 20 , hour = 10 ),
1105+ end_datetime = _datetime (day = 20 , hour = 12 ),
1106+ )
1107+
1108+ response = graphql (
1109+ reservation_units_reservable_query (
1110+ pk = reservation_unit .pk ,
1111+ fields = "pk isClosed firstReservableDatetime" ,
1112+ )
1113+ )
1114+
1115+ assert response .has_errors is False , response
1116+ assert len (response .edges ) == 1 , response
1117+ assert response .node (0 ) == {
1118+ "pk" : reservation_unit .pk ,
1119+ "isClosed" : False ,
1120+ "firstReservableDatetime" : None ,
1121+ }
1122+
1123+
10721124########################################################################################################################
10731125
10741126
0 commit comments