def test_populate_user_from_tree_affiliation(self): owner = Owner.objects.get(user__username="******") user = User.objects.get(username="******") self.assertEqual(user.owner, owner) reload(populatedCASbackend) tree = ET.fromstring(self.xml_string) populatedCASbackend.populate_user_from_tree(user, owner, tree) self.assertEqual(AccessGroup.objects.all().count(), 3) self.assertTrue( user.owner.accessgroup_set.filter( code_name__in=["member", "staff"]).exists()) print(" ---> test_populate_user_from_tree_affiliation" " of PopulatedCASTestCase : OK !")
def test_populate_user_from_tree(self): owner = Owner.objects.get(user__username="******") user = User.objects.get(username="******") self.assertEqual(user.owner, owner) tree = ET.fromstring(self.xml_string) reload(populatedCASbackend) populatedCASbackend.populate_user_from_tree(user, owner, tree) self.assertEqual(user.email, "*****@*****.**") self.assertEqual(user.first_name, "Univ") self.assertEqual(user.last_name, "Pod") # CREATE_GROUP_FROM_AFFILIATION = getattr( # settings, 'CREATE_GROUP_FROM_AFFILIATION', False) # CREATE_GROUP_FROM_GROUPS = getattr( # settings, 'CREATE_GROUP_FROM_GROUPS', False) # check no group are created any from affiliation or groups self.assertEqual(user.is_staff, True) self.assertEqual(AccessGroup.objects.all().count(), 1) self.assertEqual(user.owner.accessgroup_set.all().count(), 0) print(" ---> test_populate_user_from_tree by default" " of PopulatedCASTestCase : OK !")