示例#1
0
  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, [])
示例#2
0
  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, [])
示例#3
0
  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)
示例#4
0
  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])