Exemplo n.º 1
0
 def test_create_new_event(self):
     courtcase = CourtCaseFactory()
     session_row = SessionRowFactory(signature=courtcase.signature)
     my_mock = mock.Mock(get_session_rows=lambda: [session_row])
     self.manager.handle_court(courtcase.court, my_mock)
     event = Event.objects.get()
     self.assertEqual(event.time, session_row.datetime)
     self.assertEqual(event.text, session_row.description)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def test_update_event_text_on_new_session_row_text(self):
     courtsession = CourtSessionFactory()
     courtcase = courtsession.courtcase
     old_event = courtsession.event
     session_row = SessionRowFactory(signature=courtcase.signature,
                                     datetime=old_event.time)
     my_mock = mock.Mock(get_session_rows=lambda: [session_row])
     self.manager.handle_court(courtsession.courtcase.court, my_mock)
     self.assertEqual(Event.objects.count(), 1)
     old_event.refresh_from_db()
     self.assertEqual(old_event.time, session_row.datetime)
     self.assertEqual(old_event.text, session_row.description)
     self.assertEqual(old_event.modified_by, self.user)
Exemplo n.º 4
0
 def test_skip_unknown_signature_row(self):
     session_row = SessionRowFactory()
     my_mock = mock.Mock(get_session_rows=lambda: [session_row])
     self.manager.handle_court(CourtFactory(), my_mock)
     self.assertEqual(Event.objects.count(), 0)