Exemplo n.º 1
0
    def test_user_is_not_staff(self):
        """ Validate the querysets returned for a user that is not staff.
            Regular users should only have access to view sessions in the
            organization that they belong to.
        """

        # Get the querysets
        querysets = get_queryset(self.user)

        # Organizations
        self.assertEqual(1, len(querysets['organizations']), "There is only one org")
        self.assertIn(self.info.organization, querysets['organizations'])

        # Sessions
        for session in Session.objects.filter(organization=self.info.organization):
            self.assertIn(session, querysets['sessions'])
Exemplo n.º 2
0
    def test_user_is_staff(self):
        """ Validate the querysets returned from a user that is staff.
            Staff should have access to view all sessions in all
            organizations. Verify that that is what is returned.
        """

        # Set user as staff
        self.user.is_staff = True
        self.user.save()

        # Generate querysets
        querysets = get_queryset(self.user)

        # Organizatioins
        for organization in Organization.objects.all():
            self.assertIn(organization, querysets['organizations'])

        # Sessions
        for session in Session.objects.all():
            self.assertIn(session, querysets['sessions'])