Ejemplo n.º 1
0
 def test_assign_display_institutions(self):
     self.login_permitted_user()
     institution_1 = InstitutionFactory()
     institution_2 = InstitutionFactory()
     response = self.client.get(self.get_url())
     self.assertContains(response, institution_1.name)
     self.assertContains(response, institution_2.name)
Ejemplo n.º 2
0
 def test_send_to_all(self):
     self.login_permitted_user()
     InstitutionFactory(name="Office 1")
     InstitutionFactory(name="Office 2")
     InstitutionFactory()
     self.client.post(self.get_url() + "?name=Office", data={"all": "yes"})
     self.send_all_pending()
     self.assertEqual(len(mail.outbox), 2)
Ejemplo n.º 3
0
    def test_limit_number_of_letters_sent_simultaneously(self):
        self.login_permitted_user()
        InstitutionFactory.create_batch(size=25, name="Office")

        response = self.client.post(self.get_url() + "?name=Office",
                                    data={"all": "yes"})
        self.send_all_pending()
        self.assertEqual(len(mail.outbox), 0)
        self.assertRedirects(response, self.get_url())
Ejemplo n.º 4
0
 def test_force_filtering_before_assign(self):
     self.login_permitted_user()
     InstitutionFactory(name="Office 1")
     InstitutionFactory(name="Office 2")
     InstitutionFactory()
     response = self.client.post(self.get_url(), data={"all": "yes"})
     self.send_all_pending()
     self.assertEqual(len(mail.outbox), 0)
     self.assertRedirects(response, self.get_url())
Ejemplo n.º 5
0
 def test_assing_using_custom_domain(self):
     self.monitoring.domain = DomainFactory(name="custom-domain.com")
     self.monitoring.save()
     self.login_permitted_user()
     InstitutionFactory(name="Office 1")
     InstitutionFactory(name="Office 2")
     InstitutionFactory()
     self.client.post(self.get_url() + "?name=Office", data={"all": "yes"})
     self.send_all_pending()
     self.assertEqual(len(mail.outbox), 2)
     self.assertTrue(
         mail.outbox[0].from_email.endswith("custom-domain.com"))
Ejemplo n.º 6
0
 def test_send_to_selected(self):
     self.login_permitted_user()
     institution_1 = InstitutionFactory(name="Office 1")
     institution_2 = InstitutionFactory(name="Office 2")
     InstitutionFactory()
     to_send_ids = [institution_1.pk, institution_2.pk]
     self.client.post(self.get_url() + "?name=",
                      data={"to_assign": to_send_ids})
     self.send_all_pending()
     self.assertEqual(len(mail.outbox), 2)
     self.assertEqual(mail.outbox[0].to[0], institution_1.email)
     self.assertEqual(mail.outbox[1].to[0], institution_2.email)
     for x in (0, 1):
         self.assertEqual(mail.outbox[x].subject, "Wniosek")
Ejemplo n.º 7
0
 def test_standard_save(self):
     data = {"name": "example", "institution": InstitutionFactory().pk}
     form = CaseForm(monitoring=self.case.monitoring, user=self.user, data=data)
     self.assertTrue(form.is_valid(), msg=form.errors)
     obj = form.save()
     self.assertEqual(obj.name, "example")
     self.assertEqual(obj.monitoring, self.case.monitoring)
     self.assertEqual(obj.user, self.user)
Ejemplo n.º 8
0
 def test_update_email_after_send(self):
     self.login_permitted_user()
     institution = InstitutionFactory(name="Office 1")
     to_send_ids = [institution.pk]
     self.client.post(self.get_url() + "?name=",
                      data={"to_assign": to_send_ids})
     self.send_all_pending()
     case = Case.objects.filter(monitoring=self.monitoring,
                                institution=institution).get()
     self.assertTrue(case.email)
Ejemplo n.º 9
0
    def test_constant_increment_local_id(self):
        self.login_permitted_user()
        institution_1 = InstitutionFactory(name="Office 1")
        institution_2 = InstitutionFactory(name="Office 2")
        institution_3 = InstitutionFactory(name="Office 3")
        self.client.post(self.get_url() + "?name=Office",
                         data={"to_assign": [institution_1.pk]})
        self.send_all_pending()
        self.assertEqual(len(mail.outbox), 1)

        self.assertTrue(Case.objects.latest().name.endswith(" #1"),
                        msg=Case.objects.latest().name)

        self.client.post(
            self.get_url() + "?name=Office",
            data={"to_assign": [institution_2.pk, institution_3.pk]},
        )
        self.send_all_pending()
        self.assertEqual(len(mail.outbox), 3)
        self.assertTrue(institution_2.case_set.all()[0].name.endswith(" #2"))
        self.assertTrue(institution_3.case_set.all()[0].name.endswith(" #3"))

        for x in (0, 1, 2):
            self.assertEqual(mail.outbox[x].subject, "Wniosek")