Пример #1
0
  def testForUserWithNoRole(self):
    """Tests that a user with no role is promoted to an org admin role."""
    profile_logic.assignOrgAdminRoleForOrg(self.profile, self.org.key)

    self.assertTrue(self.profile.is_mentor)
    self.assertListEqual(self.profile.mentor_for, [self.org.key])
    self.assertTrue(self.profile.is_admin)
    self.assertListEqual(self.profile.admin_for, [self.org.key])
Пример #2
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.assignOrgAdminRoleForOrg(
        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)
Пример #3
0
  def testForMentorForAnotherOrg(self):
    """Tests that a user is still only a mentor for another organization."""
    # seed another organization
    other_org = org_utils.seedOrganization(self.program.key())

    self.profile.mentor_for = [other_org.key]
    self.profile.put()

    profile_logic.assignOrgAdminRoleForOrg(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, [self.org.key])