@@ -199,6 +199,7 @@ class ValidateOIDCAPITestCase(BaseAPITestCase):
199199 }
200200
201201 def setUp (self ):
202+ self .abakus_group = AbakusGroup .objects .get (name = "Abakus" )
202203 self .grade_data_1 = AbakusGroup .objects .create (
203204 name = constants .FIRST_GRADE_DATA , type = constants .GROUP_GRADE
204205 )
@@ -214,6 +215,7 @@ def setUp(self):
214215
215216 self .user_with_student_confirmation = User .objects .get (username = "test1" )
216217 self .grade_data_4 .add_user (self .user_with_student_confirmation )
218+ self .abakus_group .add_user (self .user_with_student_confirmation )
217219 self .user_without_student_confirmation = User .objects .get (username = "test2" )
218220
219221 self .client .force_authenticate (self .user_without_student_confirmation )
@@ -234,6 +236,11 @@ def test_data_1st(self, *args):
234236 self .assertEqual (
235237 self .user_without_student_confirmation .grade .id , self .grade_data_1 .id
236238 )
239+ self .assertTrue (
240+ self .user_without_student_confirmation .abakus_groups .filter (
241+ pk = self .abakus_group .pk
242+ ).exists ()
243+ )
237244
238245 @mock .patch ("lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .KOMTEK ))
239246 def test_komtek_1st (self , * args ):
@@ -245,6 +252,11 @@ def test_komtek_1st(self, *args):
245252 self .assertEqual (
246253 self .user_without_student_confirmation .grade .id , self .grade_komtek_1 .id
247254 )
255+ self .assertTrue (
256+ self .user_without_student_confirmation .abakus_groups .filter (
257+ pk = self .abakus_group .pk
258+ ).exists ()
259+ )
248260
249261 @mock .patch (
250262 "lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .DATA_MASTER )
@@ -260,6 +272,11 @@ def test_data_4th(self, *args):
260272 self .assertEqual (
261273 self .user_without_student_confirmation .grade .id , self .grade_data_4 .id
262274 )
275+ self .assertTrue (
276+ self .user_without_student_confirmation .abakus_groups .filter (
277+ pk = self .abakus_group .pk
278+ ).exists ()
279+ )
263280
264281 @mock .patch (
265282 "lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .KOMTEK_MASTER )
@@ -275,6 +292,11 @@ def test_komtek_4th(self, *args):
275292 self .assertEqual (
276293 self .user_without_student_confirmation .grade .id , self .grade_komtek_4 .id
277294 )
295+ self .assertTrue (
296+ self .user_without_student_confirmation .abakus_groups .filter (
297+ pk = self .abakus_group .pk
298+ ).exists ()
299+ )
278300
279301 @mock .patch (
280302 "lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .SECCLO_MASTER )
@@ -290,6 +312,12 @@ def test_secclo_master(self, *args):
290312 self .assertEqual (
291313 self .user_without_student_confirmation .grade .id , self .grade_komtek_4 .id
292314 )
315+ print (self .user_without_student_confirmation .abakus_groups .all ())
316+ self .assertTrue (
317+ self .user_without_student_confirmation .abakus_groups .filter (
318+ pk = self .abakus_group .pk
319+ ).exists ()
320+ )
293321
294322 @mock .patch (
295323 "lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .MULTI_OTHER )
@@ -304,6 +332,11 @@ def test_with_other_study_informatics(self, *args):
304332 )
305333 self .assertEqual (len (json .get ("studyProgrammes" )), len (multi_other_resp ))
306334 self .assertIsNone (self .user_without_student_confirmation .grade )
335+ self .assertFalse (
336+ self .user_without_student_confirmation .abakus_groups .filter (
337+ pk = self .abakus_group .pk
338+ ).exists ()
339+ )
307340
308341 @mock .patch ("lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .DATA ))
309342 def test_valid_study_existing_grade (self , * args ):
@@ -322,6 +355,11 @@ def test_valid_study_existing_grade(self, *args):
322355 self .assertEqual (
323356 self .user_with_student_confirmation .grade .id , self .grade_data_4 .id
324357 )
358+ self .assertTrue (
359+ self .user_with_student_confirmation .abakus_groups .filter (
360+ pk = self .abakus_group .pk
361+ ).exists ()
362+ )
325363
326364 @mock .patch ("lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .INDOK ))
327365 def test_switch_to_indok (self , * args ):
@@ -340,6 +378,11 @@ def test_switch_to_indok(self, *args):
340378 self .user_with_student_confirmation .grade .id , self .grade_data_4 .id
341379 )
342380 self .assertTrue (self .user_with_student_confirmation .is_verified_student ())
381+ self .assertTrue (
382+ self .user_with_student_confirmation .abakus_groups .filter (
383+ pk = self .abakus_group .pk
384+ ).exists ()
385+ )
343386
344387 @mock .patch ("lego.apps.users.views.oidc.oauth.feide" , MockFeideOAUTH (Token .DATA ))
345388 def test_multiple_users_one_feide (self , * args ):
@@ -365,3 +408,8 @@ def test_multiple_users_one_feide(self, *args):
365408 self .user_with_student_confirmation .student_username ,
366409 user_without_student_confirmation .student_username ,
367410 )
411+ self .assertFalse (
412+ self .user_without_student_confirmation .abakus_groups .filter (
413+ pk = self .abakus_group .pk
414+ ).exists ()
415+ )
0 commit comments