Example #1
0
class SnailMailTaskViewTests(TestCase):
    """Tests SnailMailTask-specific POST handlers"""

    def setUp(self):
        self.url = reverse('snail-mail-task-list')
        self.task = SnailMailTaskFactory()
        user = UserFactory(username='******', is_staff=True)
        self.client = Client()
        self.client.force_login(user)

    def test_get_single(self):
        """Should be able to view a single task"""
        response = self.client.get(
            reverse('snail-mail-task', kwargs={
                'pk': self.task.pk
            })
        )
        eq_(response.status_code, 200)

    def test_post_set_status(self):
        """Should update the status of the task's communication and associated
        request.
        """
        new_status = 'ack'
        self.client.post(
            self.url,
            {
                'status': new_status,
                'task': self.task.pk,
                'save': True,
            },
        )
        updated_task = SnailMailTask.objects.get(pk=self.task.pk)
        eq_(updated_task.communication.status, new_status)
        eq_(updated_task.communication.foia.status, new_status)

    def test_post_record_check(self):
        """A payment snail mail task should record the check number."""
        check_number = 42
        self.task.category = 'p'
        self.task.save()
        self.client.post(
            self.url, {
                'status': 'ack',
                'check_number': check_number,
                'task': self.task.pk,
                'save': True,
            }
        )
        self.task.refresh_from_db()
        check = Check.objects.filter(communication=self.task.communication
                                     ).first()
        ok_(check, 'A check should be generated.')

    @tag('slow')
    def _test_n_plus_one_query(self):
        """Should make the same number of SQL queries regardless of amount of data"""
        n_plus_one_query(self.client, self.url, SnailMailTaskFactory)
Example #2
0
class SnailMailTaskViewTests(TestCase):
    """Tests SnailMailTask-specific POST handlers"""
    def setUp(self):
        self.url = reverse('snail-mail-task-list')
        self.task = SnailMailTaskFactory()
        UserFactory(username='******', password='******', is_staff=True)
        self.client = Client()
        self.client.login(username='******', password='******')

    def test_get_single(self):
        """Should be able to view a single task"""
        response = self.client.get(
            reverse('snail-mail-task', kwargs={'pk': self.task.pk}))
        eq_(response.status_code, 200)

    def test_post_set_status(self):
        """Should update the status of the task's communication and associated
        request.
        """
        new_status = 'ack'
        self.client.post(
            self.url,
            {
                'status': new_status,
                'task': self.task.pk,
                'save': True,
            },
        )
        updated_task = SnailMailTask.objects.get(pk=self.task.pk)
        eq_(updated_task.communication.status, new_status)
        eq_(updated_task.communication.foia.status, new_status)

    def test_post_record_check(self):
        """A payment snail mail task should record the check number."""
        check_number = 42
        self.task.category = 'p'
        self.task.save()
        self.client.post(
            self.url, {
                'status': 'ack',
                'check_number': check_number,
                'task': self.task.pk,
                'save': True,
            })
        self.task.refresh_from_db()
        note = FOIANote.objects.filter(
            foia=self.task.communication.foia).first()
        ok_(note, 'A note should be generated.')
Example #3
0
 def test_snail_mail_prepare(self):
     """Generate a SnailMailPDF"""
     snail = SnailMailTaskFactory()
     pdf = SnailMailPDF(
         snail.communication, snail.category, snail.switch, snail.amount
     )
     prepared_pdf, page_count, files, mail = pdf.prepare()
     ok_(prepared_pdf)
     eq_(page_count, 1)
     eq_(files, [])
     ok_(isinstance(mail, MailCommunication))
Example #4
0
 def setUp(self):
     AgencyFactory()
     ArticleFactory()
     CrowdsourceResponseFactory()
     FOIARequestFactory()
     FlaggedTaskFactory()
     NewAgencyTaskFactory()
     OrphanTaskFactory()
     QuestionFactory()
     ResponseTaskFactory()
     SnailMailTaskFactory()
     UserFactory()
Example #5
0
 def setUp(self):
     self.url = reverse("snail-mail-task-list")
     self.task = SnailMailTaskFactory()
     user = UserFactory(username="******", is_staff=True)
     self.client = Client()
     self.client.force_login(user)
Example #6
0
 def setUp(self):
     self.url = reverse('snail-mail-task-list')
     self.task = SnailMailTaskFactory()
     UserFactory(username='******', password='******', is_staff=True)
     self.client = Client()
     self.client.login(username='******', password='******')