Ejemplo n.º 1
0
    def test_has_assignees_lifecycle(self):
        user = UserFactory(is_staff=True)
        self.assertFalse(self.object.has_assignees())

        permission = CaseUserObjectPermissionFactory(
            content_object=self.object,
            permission_name="can_send_to_client",
            user=user,
        )
        self.assertTrue(self.object.has_assignees())

        permission.delete()
        self.assertFalse(self.object.has_assignees())
Ejemplo n.º 2
0
 def test_against_unnecessary_changes(self):
     courtcase = CourtCaseFactory(court__parser_key='WSA_Gdansk',
                                  signature='II SA/Gd 243/18')
     CaseUserObjectPermissionFactory(content_object=courtcase.case,
                                     permission_name='can_send_to_client',
                                     user__is_staff=True)
     self.manager.handle_court(courtcase.court)
     self.assertTrue(len(mail.outbox) == 1)
     self.manager.handle_court(courtcase.court)
     self.assertTrue(len(mail.outbox) == 1, mail)
Ejemplo n.º 3
0
    def test_sending_notification_if_no_profile(self):
        cuop = CaseUserObjectPermissionFactory(user__profile=None,
                                               user__is_staff=True,
                                               content_object=self.case)
        event_to_trigger = EventFactory(case=self.case, time=timezone.now())
        management.call_command('send_event_reminders', stdout=self.stdout)

        self.assertTrue(
            cuop.user.reminder_set.filter(event=event_to_trigger).exists())

        email = mail.outbox.pop()
        self.assertIn(cuop.user.email, email.recipients())
Ejemplo n.º 4
0
    def test_notify_about_update_event(self):
        cuop = CaseUserObjectPermissionFactory(
            user__is_staff=True, permission_name="can_send_to_client")

        courtcase = CourtCaseFactory(case=cuop.content_object)
        session_row = SessionRowFactory(signature=courtcase.signature)
        my_mock = mock.Mock(get_session_rows=lambda: [session_row])
        self.manager.handle_court(courtcase.court, my_mock)

        self.assertEqual(len(mail.outbox), 1)
        new_mail = mail.outbox.pop()

        self.assertIn(courtcase.signature, new_mail.body)
Ejemplo n.º 5
0
        self.assertEqual(eml_content, "12345")
        self.assertEqual(attachment_content, "my-content")

    def test_reopen_case_free(self):
        case = CaseFactory(status=Case.STATUS.closed, handled=True)
        response = self.client.post(path=self.authenticated_url,
                                    data=self._get_body(case))
        self.assertEqual(response.json()["status"], "OK")
        self.assertEqual(Case.objects.get(pk=case.pk).status, Case.STATUS.free)
        self.assertEqual(Case.objects.get(pk=case.pk).handled, False)

    def test_reopen_case_assigned(self):
        case = CaseFactory(status=Case.STATUS.closed, handled=True)
        CaseUserObjectPermissionFactory(
            content_object=case,
            permission_name="can_send_to_client",
            user__is_staff=True,
        )
        response = self.client.post(path=self.authenticated_url,
                                    data=self._get_body(case))
        self.assertEqual(response.json()["status"], "OK")
        self.assertEqual(
            Case.objects.get(pk=case.pk).status, Case.STATUS.assigned)
        self.assertEqual(Case.objects.get(pk=case.pk).handled, False)

    def test_no_valid_email(self):
        response = self.client.post(path=self.authenticated_url,
                                    data=self._get_body())
        letter = Letter.objects.first()
        self.assertEqual(response.status_code, 200)
        self.assertEqual(letter.case.created_by.email, "*****@*****.**")