def test_ticket_reports_per_queue_user_restrictions(self):
        """
        Ensure that while the superuser can generate reports on all queues and
        tickets, user_1 can only generate reports for queue 1 and user_2 can
        only do so for queue 2
        """
        # Regular users
        for identifier in self.IDENTIFIERS:
            self.client.login(username='User_%d' % identifier, password=identifier)
            response = self.client.get(
                reverse('helpdesk_run_report', kwargs={'report': 'userqueue'})
            )
            # Only two columns of data should be present: ticket counts for
            # unassigned and this user only
            self.assertEqual(
                len(response.context['data']),
                2,
                'Queues in report were not properly limited by queue membership'
            )
            # Each user should see a total number of tickets equal to twice their ID
            self.assertEqual(
                sum([sum(user_tickets[1:]) for user_tickets in response.context['data']]),
                identifier * 2,
                'Tickets in report were not properly limited by queue membership'
            )
            # Each user should only be able to pick 1 queue
            self.assertEqual(
                len(response.context['headings']),
                2,
                'Queue choices were not properly limited by queue membership'
            )
            # The queue each user can pick should be the queue named after their ID
            self.assertEqual(
                response.context['headings'][1],
                "Queue %d" % identifier,
                'Queue choices were not properly limited by queue membership'
            )

        # Superuser
        self.client.login(username='superuser', password='superuser')
        response = self.client.get(
            reverse('helpdesk_run_report', kwargs={'report': 'userqueue'})
        )
        # Superuser should see ticket counts for all two queues, which includes
        # three columns: unassigned and both user 1 and user 2
        self.assertEqual(
            len(response.context['data'][0]),
            3,
            'Queues in report were improperly limited by queue membership for a superuser'
        )
        # Superuser should see the total ticket count of three tickets
        self.assertEqual(
            sum([sum(user_tickets[1:]) for user_tickets in response.context['data']]),
            6,
            'Tickets in report were improperly limited by queue membership for a superuser'
        )
        self.assertEqual(
            len(response.context['headings']),
            3,
            'Queue choices were improperly limited by queue membership for a superuser'
        )
dataset/ETHPy150Open rossp/django-helpdesk/helpdesk/tests/test_per_queue_staff_permission.py/PerQueueStaffMembershipTestCase.test_ticket_reports_per_queue_user_restrictions/original