예제 #1
0
    def setUp(self):
        """Set up required for the view tests.
    """

        self.view = TestView()
        self.stubout_helper = StuboutHelper()
        self.stubout_helper.stuboutBase()
예제 #2
0
class BaseTest(unittest.TestCase):
    """Tests related to the base view.
  """
    def setUp(self):
        """Set up required for the view tests.
    """

        self.view = TestView()
        self.stubout_helper = StuboutHelper()
        self.stubout_helper.stuboutBase()

    def tearDown(self):
        """Tears down the test environment.
    """

        self.stubout_helper.tearDown()

    def testErrorOnNonExistantEntity(self):
        """
    """

        request = MockRequest("/test/public")
        request.start()
        access_type = "show"
        page_name = "Show Test"
        django_args = {'link_id': 'foo', 'scope_path': 'bar'}
        actual = self.view.public(request,
                                  access_type,
                                  page_name=page_name,
                                  **django_args)
        request.end()
        self.assertTrue('error' in actual)
예제 #3
0
class BaseTest(unittest.TestCase):
  """Tests related to the base view.
  """

  def setUp(self):
    """Set up required for the view tests.
    """

    self.view = TestView()
    self.stubout_helper = StuboutHelper()
    self.stubout_helper.stuboutBase()

  def tearDown(self):
    """Tears down the test environment.
    """

    self.stubout_helper.tearDown()

  def testErrorOnNonExistantEntity(self):
    """
    """

    request = MockRequest("/test/public")
    request.start()
    access_type = "show"
    page_name = "Show Test"
    django_args = {'link_id': 'foo', 'scope_path': 'bar'}
    actual = self.view.public(request, access_type, page_name=page_name,
                              **django_args)
    request.end()
    self.assertTrue('error' in actual)
예제 #4
0
  def setUp(self):
    """Set up required for the view tests.
    """

    self.view = TestView()
    self.stubout_helper = StuboutHelper()
    self.stubout_helper.stuboutBase()
예제 #5
0
    def setUp(self):
        """Set up required for the view tests.
    """

        self.view = TestView()
        self.stubout_helper = StuboutHelper()
        self.stubout_helper.stuboutBase()
        self.stubout_helper.stuboutElement(task.View, 'select',
                                           ['request', 'view', 'redirect'])

        # map all the models
        models_dict = {
            'User': models.user.User,
            'Site': models.site.Site,
            'Sponsor': models.sponsor.Sponsor,
            'Host': models.host.Host,
            'GCITimeline': gci_models.timeline.GCITimeline,
            'GCIProgram': gci_models.program.GCIProgram,
            'GCIOrganization': gci_models.organization.GCIOrganization,
            'GCIOrgAdmin': gci_models.org_admin.GCIOrgAdmin,
            'GCIMentor': gci_models.mentor.GCIMentor,
            'GCIStudent': gci_models.student.GCIStudent,
            'GCITask': gci_models.task.GCITask,
        }

        # create a fixture for Appengine datastore using the previous map
        datafixture = GoogleDatastoreFixture(env=models_dict,
                                             style=NamedDataStyle())

        # seed the data in the datastore
        self.data = datafixture.data(
            datasets.UserData, datasets.SiteData, datasets.SponsorData,
            datasets.HostData, datasets.GCITimelineData,
            datasets.GCIProgramData, datasets.GCIOrganizationData,
            datasets.GCIOrgAdminData, datasets.GCIMentorData,
            datasets.GCIMentorData, datasets.GCITaskData)

        self.data.setup()
예제 #6
0
  def setUp(self):
    """Set up required for the view tests.
    """

    self.view = TestView()
    self.stubout_helper = StuboutHelper()
    self.stubout_helper.stuboutBase()
    self.stubout_helper.stuboutElement(task.View, 'select',
                                       ['request', 'view', 'redirect'])

    # map all the models
    models_dict = {
        'User': models.user.User,
        'Site': models.site.Site,
        'Sponsor': models.sponsor.Sponsor,
        'Host': models.host.Host,
        'GCITimeline': gci_models.timeline.GCITimeline,
        'GCIProgram': gci_models.program.GCIProgram,
        'GCIOrganization': gci_models.organization.GCIOrganization,
        'GCIOrgAdmin': gci_models.org_admin.GCIOrgAdmin,
        'GCIMentor': gci_models.mentor.GCIMentor,
        'GCIStudent': gci_models.student.GCIStudent,
        'GCITask': gci_models.task.GCITask,
        }

    # create a fixture for Appengine datastore using the previous map
    datafixture = GoogleDatastoreFixture(env=models_dict,
                                         style=NamedDataStyle())

    # seed the data in the datastore
    self.data = datafixture.data(
        datasets.UserData, datasets.SiteData, datasets.SponsorData,
        datasets.HostData, datasets.GCITimelineData, datasets.GCIProgramData,
        datasets.GCIOrganizationData, datasets.GCIOrgAdminData,
        datasets.GCIMentorData, datasets.GCIMentorData,
        datasets.GCITaskData)

    self.data.setup()
예제 #7
0
class TaskTest(unittest.TestCase):
    """Tests related to the GCI task view.
  """
    def setUp(self):
        """Set up required for the view tests.
    """

        self.view = TestView()
        self.stubout_helper = StuboutHelper()
        self.stubout_helper.stuboutBase()
        self.stubout_helper.stuboutElement(task.View, 'select',
                                           ['request', 'view', 'redirect'])

        # map all the models
        models_dict = {
            'User': models.user.User,
            'Site': models.site.Site,
            'Sponsor': models.sponsor.Sponsor,
            'Host': models.host.Host,
            'GCITimeline': gci_models.timeline.GCITimeline,
            'GCIProgram': gci_models.program.GCIProgram,
            'GCIOrganization': gci_models.organization.GCIOrganization,
            'GCIOrgAdmin': gci_models.org_admin.GCIOrgAdmin,
            'GCIMentor': gci_models.mentor.GCIMentor,
            'GCIStudent': gci_models.student.GCIStudent,
            'GCITask': gci_models.task.GCITask,
        }

        # create a fixture for Appengine datastore using the previous map
        datafixture = GoogleDatastoreFixture(env=models_dict,
                                             style=NamedDataStyle())

        # seed the data in the datastore
        self.data = datafixture.data(
            datasets.UserData, datasets.SiteData, datasets.SponsorData,
            datasets.HostData, datasets.GCITimelineData,
            datasets.GCIProgramData, datasets.GCIOrganizationData,
            datasets.GCIOrgAdminData, datasets.GCIMentorData,
            datasets.GCIMentorData, datasets.GCITaskData)

        self.data.setup()

    def tearDown(self):
        """Clears everything that is setup for the tests
    """

        self.data.teardown()
        self.stubout_helper.tearDown()

    def testCreateRedirectAsDeveloper(self):
        """Tests if the Developer is redirected to the page containing
    all the Organizations under the Program to chose from
    """

        from soc.modules.gci.views.models.organization import View

        request = MockRequest("/test/gci/task/create")
        request.start()
        access_type = "create"
        page_name = "Create Task"
        kwargs = {}
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()

        self.assertTrue('redirect' in actual
                        and isinstance(actual['redirect'], View))

    def testCreateRights(self):
        """Tests if the Developer/Org Admin have rights create tasks and
    other users don't have.
    """

        request = MockRequest("/test/gci/task/create/google/gci2009/melange")
        # test if the Org Admin of the Organization passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        access_type = "create"
        page_name = "Create Task"
        kwargs = {'scope_path': 'google/gci2009/melange'}
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if the Developer passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if the Org Admin of other Organization doesn't passes
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if the Mentor of the Organization doesn't passes
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if the Mentor of other Organization doesn't passes
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if the Student of the Organization doesn't passes
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if person with no role in Melange doesn't pass
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.create(request,
                                  access_type,
                                  page_name=page_name,
                                  **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

    def testSuggestTask(self):
        """Tests if the Mentor have rights create tasks and
    other users don't have.
    """

        request = MockRequest(
            "/test/gci/task/suggest_task/google/gci2009/melange")

        # test if mentor of the Organization passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        access_type = "suggest_task"
        page_name = "Suggest Task"
        kwargs = {'scope_path': 'google/gci2009/melange'}
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if mentor of other Organization doesn't pass the
        # access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if Org Admin of the Organization passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if Org Admin of other Organization doesn't pass
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if Developer passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if student of the Organization doesn't pass
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if student of other Organization doesn't pass
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if user who doesn't have any role in Melange
        # doesn't pass the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.suggestTask(request,
                                       access_type,
                                       page_name=page_name,
                                       **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

    def testEditTask(self):
        """Tests if the Mentor/OrgAdmin have rights to edit tasks and
    other users don't have.
    """

        request = MockRequest(
            "/test/gci/task/edit/google/gci2009/melange/t126518233415")

        # test if Developer passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        access_type = "edit"
        page_name = "Edit Task"
        kwargs = {
            'scope_path': 'google/gci2009/melange',
            'link_id': 't126518233415'
        }
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if Org Admin of the Organization passes the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' not in actual)

        # test if Org Admin of other Organization doesn't passes the
        # access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if mentor of the Organization doesn't passes the
        # access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if mentor of other Organization doesn't passes the
        # access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if student of the Organization doesn't pass
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if student of other Organization doesn't pass
        # the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))

        # test if user who doesn't have any role in Melange
        # doesn't pass the access check
        os.environ['USER_EMAIL'] = '*****@*****.**'
        request.start()
        actual = self.view.edit(request,
                                access_type,
                                page_name=page_name,
                                **kwargs)
        request.end()
        self.assertTrue('error' in actual
                        and isinstance(actual['error'], AccessViolation))
예제 #8
0
class TaskTest(unittest.TestCase):
  """Tests related to the GCI task view.
  """

  def setUp(self):
    """Set up required for the view tests.
    """

    self.view = TestView()
    self.stubout_helper = StuboutHelper()
    self.stubout_helper.stuboutBase()
    self.stubout_helper.stuboutElement(task.View, 'select',
                                       ['request', 'view', 'redirect'])

    # map all the models
    models_dict = {
        'User': models.user.User,
        'Site': models.site.Site,
        'Sponsor': models.sponsor.Sponsor,
        'Host': models.host.Host,
        'GCITimeline': gci_models.timeline.GCITimeline,
        'GCIProgram': gci_models.program.GCIProgram,
        'GCIOrganization': gci_models.organization.GCIOrganization,
        'GCIOrgAdmin': gci_models.org_admin.GCIOrgAdmin,
        'GCIMentor': gci_models.mentor.GCIMentor,
        'GCIStudent': gci_models.student.GCIStudent,
        'GCITask': gci_models.task.GCITask,
        }

    # create a fixture for Appengine datastore using the previous map
    datafixture = GoogleDatastoreFixture(env=models_dict,
                                         style=NamedDataStyle())

    # seed the data in the datastore
    self.data = datafixture.data(
        datasets.UserData, datasets.SiteData, datasets.SponsorData,
        datasets.HostData, datasets.GCITimelineData, datasets.GCIProgramData,
        datasets.GCIOrganizationData, datasets.GCIOrgAdminData,
        datasets.GCIMentorData, datasets.GCIMentorData,
        datasets.GCITaskData)

    self.data.setup()

  def tearDown(self):
    """Clears everything that is setup for the tests
    """

    self.data.teardown()
    self.stubout_helper.tearDown()

  def testCreateRedirectAsDeveloper(self):
    """Tests if the Developer is redirected to the page containing
    all the Organizations under the Program to chose from
    """

    from soc.modules.gci.views.models.organization import View

    request = MockRequest("/test/gci/task/create")
    request.start()
    access_type = "create"
    page_name = "Create Task"
    kwargs = {}
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()

    self.assertTrue('redirect' in actual
        and isinstance(actual['redirect'], View))

  def testCreateRights(self):
    """Tests if the Developer/Org Admin have rights create tasks and
    other users don't have.
    """

    request = MockRequest("/test/gci/task/create/google/gci2009/melange")
    # test if the Org Admin of the Organization passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    access_type = "create"
    page_name = "Create Task"
    kwargs = {'scope_path': 'google/gci2009/melange'}
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if the Developer passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if the Org Admin of other Organization doesn't passes
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if the Mentor of the Organization doesn't passes
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if the Mentor of other Organization doesn't passes
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if the Student of the Organization doesn't passes
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if person with no role in Melange doesn't pass
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.create(request, access_type,
                              page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

  def testSuggestTask(self):
    """Tests if the Mentor have rights create tasks and
    other users don't have.
    """

    request = MockRequest(
        "/test/gci/task/suggest_task/google/gci2009/melange")

    # test if mentor of the Organization passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    access_type = "suggest_task"
    page_name = "Suggest Task"
    kwargs = {'scope_path': 'google/gci2009/melange'}
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if mentor of other Organization doesn't pass the
    # access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if Org Admin of the Organization passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if Org Admin of other Organization doesn't pass
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if Developer passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if student of the Organization doesn't pass
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if student of other Organization doesn't pass
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if user who doesn't have any role in Melange
    # doesn't pass the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.suggestTask(request, access_type,
                                   page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

  def testEditTask(self):
    """Tests if the Mentor/OrgAdmin have rights to edit tasks and
    other users don't have.
    """

    request = MockRequest(
        "/test/gci/task/edit/google/gci2009/melange/t126518233415")

    # test if Developer passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**' 
    access_type = "edit"
    page_name = "Edit Task"
    kwargs = {'scope_path': 'google/gci2009/melange',
              'link_id': 't126518233415'}
    request.start()
    actual = self.view.edit(request, access_type,
                            page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if Org Admin of the Organization passes the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                            page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' not in actual)

    # test if Org Admin of other Organization doesn't passes the
    # access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                                page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if mentor of the Organization doesn't passes the
    # access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                                page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if mentor of other Organization doesn't passes the
    # access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                                page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if student of the Organization doesn't pass
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                                page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if student of other Organization doesn't pass
    # the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                                page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))

    # test if user who doesn't have any role in Melange
    # doesn't pass the access check
    os.environ['USER_EMAIL'] = '*****@*****.**'
    request.start()
    actual = self.view.edit(request, access_type,
                                page_name=page_name, **kwargs)
    request.end()
    self.assertTrue('error' in actual and isinstance(
        actual['error'], AccessViolation))