def testForUserWithNoRole(self): """Tests that a user with no role is promoted to a mentor role.""" profile_logic.assignMentorRoleForOrg(self.profile, self.org.key) self.assertTrue(self.profile.is_mentor) self.assertListEqual(self.profile.mentor_for, [self.org.key]) self.assertFalse(self.profile.is_admin) self.assertListEqual(self.profile.admin_for, [])
def testForUserWithOrgAdminRole(self): """Tests that a user with org admin role is lowered to a mentor role.""" self.profile.mentor_for = [self.org.key] self.profile.admin_for = [self.org.key] self.profile.put() profile_logic.assignMentorRoleForOrg(self.profile, self.org.key) self.assertTrue(self.profile.is_mentor) self.assertListEqual(self.profile.mentor_for, [self.org.key]) self.assertFalse(self.profile.is_admin) self.assertListEqual(self.profile.admin_for, [])
def testOrgMemberWelcomeEmailSent(self): """Tests that welcome email is sent if needed.""" program_messages = program_utils.seedProgramMessages( program_key=self.program.key()) site = program_utils.seedSite() profile_logic.assignMentorRoleForOrg( self.profile, self.org.key, send_org_member_welcome_email=True, program=self.program, program_messages=program_messages, site=site) self.assertIn( ndb_profile_model.MessageType.ORG_MEMBER_WELCOME_MSG, self.profile.sent_messages) self.assertEmailSent(to=self.profile.contact.email)
def testForOrgAdminForAnotherOrg(self): """Tests that a user is still org admin for another organization.""" # seed another organization other_org = org_utils.seedOrganization(self.program.key()) self.profile.mentor_for = [other_org.key] self.profile.admin_for = [other_org.key] self.profile.put() profile_logic.assignMentorRoleForOrg(self.profile, self.org.key) self.assertTrue(self.profile.is_mentor) self.assertIn(self.org.key, self.profile.mentor_for) self.assertIn(other_org.key, self.profile.mentor_for) self.assertTrue(self.profile.is_admin) self.assertListEqual(self.profile.admin_for, [other_org.key])