@@ -98,6 +98,52 @@ def test_create_many(client_auth: TestClient, dbsession: Session, room_factory,
9898 assert [row .id for row in response_model .group ] == request_obj [1 ]["group_id" ]
9999
100100
101+ def test_create_many_clones (client_auth : TestClient , dbsession : Session , room_factory , group_factory , lecturer_factory ):
102+ time_stamp = datetime .datetime .now ()
103+ name1 = f"name1_{ time_stamp } "
104+ room_path1 = room_factory (client_auth )
105+ group_path1 = group_factory (client_auth )
106+ lecturer_path1 = lecturer_factory (client_auth )
107+ name2 = f"name2_{ time_stamp } "
108+ room_path2 = room_factory (client_auth )
109+ group_path2 = group_factory (client_auth )
110+ lecturer_path2 = lecturer_factory (client_auth )
111+ room_id1 = int (room_path1 .split ("/" )[- 1 ])
112+ group_id1 = int (group_path1 .split ("/" )[- 1 ])
113+ lecturer_id1 = int (lecturer_path1 .split ("/" )[- 1 ])
114+ room_id2 = int (room_path2 .split ("/" )[- 1 ])
115+ group_id2 = int (group_path2 .split ("/" )[- 1 ])
116+ lecturer_id2 = int (lecturer_path2 .split ("/" )[- 1 ])
117+ request_obj = [
118+ {
119+ "name" : name1 ,
120+ "room_id" : [room_id1 ],
121+ "group_id" : [group_id1 ],
122+ "lecturer_id" : [lecturer_id1 ],
123+ "start_ts" : "2022-08-26T22:32:38.575Z" ,
124+ "end_ts" : "2022-08-26T22:32:38.575Z" ,
125+ },
126+ {
127+ "name" : name2 ,
128+ "room_id" : [room_id2 ],
129+ "group_id" : [group_id2 ],
130+ "lecturer_id" : [lecturer_id2 ],
131+ "start_ts" : "2022-08-26T22:32:38.575Z" ,
132+ "end_ts" : "2022-08-26T22:32:38.575Z" ,
133+ },
134+ ]
135+ response = client_auth .post (f"{ RESOURCE } bulk" , json = request_obj )
136+ assert response .status_code == status .HTTP_200_OK , response .json ()
137+ assert response .json ()[0 ]["name" ] == request_obj [0 ]["name" ]
138+ response = client_auth .post (f"{ RESOURCE } bulk" , json = request_obj )
139+ assert response .status_code == status .HTTP_200_OK
140+ assert len (response .json ()) == 0
141+ events = dbsession .query (Event ).filter (Event .name == name1 ).all ()
142+ assert len (events ) == 1
143+ events = dbsession .query (Event ).filter (Event .name == name2 ).all ()
144+ assert len (events ) == 1
145+
146+
101147def test_delete (client_auth : TestClient , dbsession : Session , room_path , lecturer_path , group_path ):
102148 room_id = int (room_path .split ("/" )[- 1 ])
103149 group_id = int (group_path .split ("/" )[- 1 ])
0 commit comments