Пример #1
0
    def setUp(self):
        self.client = Client()
        self.aidant_1 = AidantFactory()
        self.aidant_2 = AidantFactory(username="******",
                                      email="*****@*****.**")
        self.usager_1 = UsagerFactory()
        self.usager_2 = UsagerFactory()

        mandat_1 = MandatFactory(
            organisation=self.aidant_1.organisation,
            usager=self.usager_1,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        self.autorisation_1_1 = AutorisationFactory(mandat=mandat_1,
                                                    demarche="Revenus")
        self.autorisation_1_2 = AutorisationFactory(
            mandat=mandat_1,
            demarche="Papiers",
            revocation_date=timezone.now())

        mandat_2 = MandatFactory(
            organisation=self.aidant_1.organisation,
            usager=self.usager_1,
            expiration_date=timezone.now() - timedelta(days=6),
        )
        self.autorisation_2_1 = AutorisationFactory(mandat=mandat_2,
                                                    demarche="Logement")

        mandat_3 = MandatFactory(
            organisation=self.aidant_2.organisation,
            usager=self.usager_2,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        self.autorisation_3_1 = AutorisationFactory(mandat=mandat_3,
                                                    demarche="Revenus")
Пример #2
0
    def setUpTestData(cls):
        cls.entry1 = Journal.objects.create(action="connect_aidant",
                                            initiator="ABC")
        cls.aidant_thierry = AidantFactory(
            username="******",
            email="*****@*****.**",
            first_name="Thierry",
            last_name="Martin",
            organisation=OrganisationFactory(name="Commune de Vernon"),
        )
        cls.usager_ned = UsagerFactory(given_name="Ned",
                                       family_name="Flanders")

        cls.first_mandat = MandatFactory(
            organisation=cls.aidant_thierry.organisation,
            usager=cls.usager_ned,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        cls.first_autorisation = AutorisationFactory(
            mandat=cls.first_mandat,
            demarche="Revenus",
        )
        Journal.log_autorisation_creation(cls.first_autorisation,
                                          aidant=cls.aidant_thierry)

        cls.mandat_thierry_ned_365 = MandatFactory(
            organisation=cls.aidant_thierry.organisation,
            usager=cls.usager_ned,
            expiration_date=timezone.now() + timedelta(days=365),
        )
    def setUp(self):
        self.aidant_thierry = AidantFactory(email="*****@*****.**")
        device = self.aidant_thierry.staticdevice_set.create(id=self.aidant_thierry.id)
        device.token_set.create(token="123456")
        self.aidant_jacqueline = AidantFactory()
        self.usager_josephine = UsagerFactory(given_name="Joséphine")
        self.mandat_thierry_josephine = MandatFactory(
            organisation=self.aidant_thierry.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        self.money_authorization = AutorisationFactory(
            mandat=self.mandat_thierry_josephine,
            demarche="argent",
        )
        self.family_authorization = AutorisationFactory(
            mandat=self.mandat_thierry_josephine,
            demarche="famille",
        )

        self.mandat_jacqueline_josephine = MandatFactory(
            organisation=self.aidant_jacqueline.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=12),
        )
        AutorisationFactory(
            mandat=self.mandat_jacqueline_josephine,
            demarche="logement",
        )
Пример #4
0
    def setUp(self):
        self.aidant = AidantFactory(email="*****@*****.**",
                                    post__with_otp_device=True)

        self.usager_josephine = UsagerFactory(given_name="Joséphine",
                                              family_name="ST-PIERRE")

        self.usager_anne = UsagerFactory(given_name="Anne Cécile Gertrude",
                                         family_name="EVALOUS")

        self.usager_corentin = UsagerFactory(given_name="Corentin",
                                             family_name="Dupont",
                                             preferred_username="******")

        MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_josephine,
            post__create_authorisations=["argent", "famille"],
        )

        ExpiredMandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_corentin,
            post__create_authorisations=["argent", "famille", "logement"],
        )

        MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_anne,
            post__create_authorisations=["argent", "famille", "logement"],
        )
Пример #5
0
 def test_show_renew_button_if_any_renewable_mandats(self):
     less_than_a_year_expired_mandat = MandatFactory(
         organisation=self.aidant_thierry.organisation,
         usager=self.usager,
         expiration_date=timezone.now() - timedelta(days=5),
         post__create_authorisations=["argent", "famille", "logement"],
     )
     revoked_mandat = RevokedMandatFactory(
         organisation=self.aidant_thierry.organisation,
         usager=self.usager,
         expiration_date=timezone.now() + timedelta(days=5),
         post__create_authorisations=["argent", "famille", "logement"],
     )
     over_a_year_expired_mandat = MandatFactory(
         organisation=self.aidant_thierry.organisation,
         usager=self.usager,
         expiration_date=timezone.now() - timedelta(days=365),
         post__create_authorisations=["argent", "famille", "logement"],
     )
     self.assertFalse(
         less_than_a_year_expired_mandat.is_active,
         "Generated mandat should not be active",
     )
     self.assertTrue(
         revoked_mandat.was_explicitly_revoked,
         "Generated mandat should be explicitly revoked",
     )
     self.assertFalse(
         over_a_year_expired_mandat.is_active,
         "Generated mandat should not be active",
     )
     self.client.force_login(self.aidant_thierry)
     self.assertEqual(Mandat.objects.count(), 3)
     response = self.client.get(reverse("usagers"))
     self.assertContains(response, "Renouveler")
Пример #6
0
    def setUp(self):
        self.client = Client()
        self.aidant_thierry = AidantFactory()
        self.aidant_yasmina = AidantFactory(
            username="******",
            organisation=self.aidant_thierry.organisation,
        )
        self.usager = UsagerFactory(given_name="Joséphine")
        self.connection = Connection.objects.create(
            state="avalidstate123",
            nonce="avalidnonce456",
            usager=self.usager,
        )
        date_further_away_minus_one_hour = datetime(
            2019, 1, 9, 8, tzinfo=pytz_timezone("Europe/Paris"))
        self.connection_2 = Connection.objects.create(
            state="test_expiration_date_triggered",
            nonce="test_nonce",
            usager=self.usager,
            expires_on=date_further_away_minus_one_hour,
        )
        mandat_creation_date = datetime(2019,
                                        1,
                                        5,
                                        3,
                                        20,
                                        34,
                                        0,
                                        tzinfo=pytz_timezone("Europe/Paris"))

        self.mandat_thierry_usager_1 = MandatFactory(
            organisation=self.aidant_thierry.organisation,
            usager=self.usager,
            expiration_date=mandat_creation_date + timedelta(days=6),
            creation_date=mandat_creation_date,
        )
        AutorisationFactory(
            mandat=self.mandat_thierry_usager_1,
            demarche="transports",
        )
        AutorisationFactory(
            mandat=self.mandat_thierry_usager_1,
            demarche="famille",
        )

        self.mandat_thierry_usager_2 = MandatFactory(
            organisation=self.aidant_thierry.organisation,
            usager=self.usager,
            expiration_date=mandat_creation_date + timedelta(days=3),
            creation_date=mandat_creation_date,
        )
        AutorisationFactory(
            mandat=self.mandat_thierry_usager_2,
            demarche="logement",
        )
    def setUp(self):
        self.aidant_thierry = AidantFactory(
            is_superuser=True, is_staff=True, is_active=True, post__with_otp_device=True
        )

        self.aidante_fatimah = AidantFactory()

        self.mandate_1 = MandatFactory(organisation=self.aidant_thierry.organisation)
        self.mandate_2 = MandatFactory(organisation=self.aidant_thierry.organisation)
        self.mandate_3 = MandatFactory(organisation=self.aidant_thierry.organisation)
        self.mandate_4 = MandatFactory(organisation=self.aidant_thierry.organisation)
Пример #8
0
    def setUp(self):
        self.client = Client()
        self.aidant_thierry = AidantFactory()
        self.aidant_jacques = AidantFactory(username="******",
                                            email="*****@*****.**")
        self.usager = UsagerFactory(given_name="Joséphine", sub="123")

        mandat_1 = MandatFactory(
            organisation=self.aidant_thierry.organisation,
            usager=self.usager,
            expiration_date=timezone.now() + timedelta(days=6),
        )

        AutorisationFactory(
            mandat=mandat_1,
            demarche="Revenus",
            revocation_date=timezone.now() - timedelta(days=1),
        )

        mandat_2 = MandatFactory(
            organisation=self.aidant_thierry.organisation,
            usager=self.usager,
            expiration_date=timezone.now() + timedelta(days=12),
        )

        AutorisationFactory(
            mandat=mandat_2,
            demarche="Famille",
        )
        AutorisationFactory(
            mandat=mandat_2,
            demarche="Revenus",
        )

        mandat_3 = MandatFactory(
            organisation=self.aidant_jacques.organisation,
            usager=self.usager,
            expiration_date=timezone.now() + timedelta(days=12),
        )
        AutorisationFactory(
            mandat=mandat_3,
            demarche="Logement",
        )
        date_further_away_minus_one_hour = datetime(
            2019, 1, 9, 8, tzinfo=pytz_timezone("Europe/Paris"))
        self.connection = Connection.objects.create(
            state="test_expiration_date_triggered",
            nonce="avalidnonce456",
            usager=self.usager,
            expires_on=date_further_away_minus_one_hour,
        )
    def setUp(self):
        self.aidant = AidantFactory(username="******")
        device = self.aidant.staticdevice_set.create(id=self.aidant.id)
        device.token_set.create(token="123456")

        self.usager_alice = UsagerFactory(given_name="Alice", family_name="Lovelace")
        self.usager_josephine = UsagerFactory(
            given_name="Joséphine", family_name="Dupont"
        )
        self.usager_corentin = UsagerFactory(
            given_name="Corentin", family_name="Dupont", preferred_username="******"
        )

        self.mandat_aidant_alice_no_autorisation = MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_alice,
            expiration_date=timezone.now() + timedelta(days=5),
        )

        self.mandat_aidant_josephine_6 = MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        AutorisationFactory(
            mandat=self.mandat_aidant_josephine_6,
            demarche="social",
        )

        self.mandat_aidant_josephine_1 = MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=1),
        )

        AutorisationFactory(
            mandat=self.mandat_aidant_josephine_1,
            demarche="papiers",
        )

        self.mandat_aidant_corentin_365 = MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_corentin,
            expiration_date=timezone.now() + timedelta(days=365),
        )
        AutorisationFactory(
            mandat=self.mandat_aidant_corentin_365,
            demarche="famille",
        )
Пример #10
0
    def setUpTestData(cls):
        cls.client = Client()

        cls.our_organisation = OrganisationFactory()
        cls.our_aidant = AidantFactory(organisation=cls.our_organisation)
        cls.our_usager = UsagerFactory()

        valid_mandat = MandatFactory(
            organisation=cls.our_organisation,
            usager=cls.our_usager,
        )
        cls.valid_autorisation = AutorisationFactory(mandat=valid_mandat,
                                                     demarche="Revenus")
        cls.revoked_autorisation = AutorisationFactory(
            mandat=valid_mandat,
            demarche="Papiers",
            revocation_date=timezone.now())

        expired_mandat = MandatFactory(
            organisation=cls.our_organisation,
            usager=cls.our_usager,
            expiration_date=timezone.now() - timedelta(days=6),
        )
        cls.expired_autorisation = AutorisationFactory(mandat=expired_mandat,
                                                       demarche="Logement")

        cls.other_organisation = OrganisationFactory(name="Other Organisation")
        cls.unrelated_usager = UsagerFactory()

        unrelated_mandat = MandatFactory(
            organisation=cls.other_organisation,
            usager=cls.unrelated_usager,
        )
        cls.unrelated_autorisation = AutorisationFactory(
            mandat=unrelated_mandat, demarche="Revenus")

        mandat_other_org_with_our_usager = MandatFactory(
            organisation=cls.other_organisation,
            usager=cls.our_usager,
        )

        cls.autorisation_other_org_with_our_usager = AutorisationFactory(
            mandat=mandat_other_org_with_our_usager, demarche="Logement")

        cls.good_combo = {
            "usager": cls.our_usager.id,
            "autorisation": cls.valid_autorisation.id,
        }
Пример #11
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.aidant = AidantFactory()
     cls.usager = UsagerFactory()
     cls.mandat = MandatFactory(organisation=cls.aidant.organisation,
                                usager=cls.usager)
     AutorisationFactory(mandat=cls.mandat)
Пример #12
0
 def setUp(self):
     self.client = Client()
     self.aidant = AidantFactory()
     self.usager = UsagerFactory()
     self.mandat = MandatFactory(organisation=self.aidant.organisation,
                                 usager=self.usager)
     AutorisationFactory(mandat=self.mandat)
Пример #13
0
    def setUpTestData(cls):
        cls.aidant_marge = AidantFactory(username="******")
        cls.aidant_patricia = AidantFactory(username="******")
        cls.usager_homer = UsagerFactory()
        cls.usager_ned = UsagerFactory(family_name="Flanders",
                                       sub="nedflanders")

        cls.mandat_marge_homer_6 = MandatFactory(
            organisation=cls.aidant_marge.organisation,
            usager=cls.usager_homer,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        cls.mandat_patricia_ned_6 = MandatFactory(
            organisation=cls.aidant_patricia.organisation,
            usager=cls.usager_ned,
            expiration_date=timezone.now() + timedelta(days=6),
        )
Пример #14
0
    def setUpTestData(cls):
        cls.client = Client()

        cls.our_organisation = OrganisationFactory()
        cls.our_aidant = AidantFactory(organisation=cls.our_organisation)
        cls.our_usager = UsagerFactory()

        cls.valid_mandat = MandatFactory(
            organisation=cls.our_organisation,
            usager=cls.our_usager,
            creation_date=datetime.datetime(
                2021, 2, 1, 13, 12, tzinfo=pytz.timezone("Europe/Paris")),
        )
        cls.valid_autorisation = AutorisationFactory(mandat=cls.valid_mandat,
                                                     demarche="Revenus")

        cls.cancelled_mandat = MandatFactory(
            organisation=cls.our_organisation,
            usager=cls.our_usager,
            creation_date=datetime.datetime(
                2021, 2, 1, 13, 12, tzinfo=pytz.timezone("Europe/Paris")),
        )
        AutorisationFactory(
            mandat=cls.cancelled_mandat,
            demarche="Revenus",
            revocation_date=timezone.now() - timedelta(minutes=5),
        )

        cls.expired_mandat = MandatFactory(
            organisation=cls.our_organisation,
            usager=cls.our_usager,
            creation_date=datetime.datetime(
                2021, 2, 1, 13, 12, tzinfo=pytz.timezone("Europe/Paris")),
            expiration_date=timezone.now() - timedelta(minutes=5),
        )
        AutorisationFactory(
            mandat=cls.expired_mandat,
            demarche="Revenus",
            revocation_date=timezone.now() - timedelta(minutes=5),
        )

        AutorisationFactory(
            mandat=cls.expired_mandat,
            demarche="Papiers",
        )
Пример #15
0
 def test_one_soon_expired_mandate(self):
     MandatFactory(organisation=self.orga, duree_keyword="LONG")
     call_command("notify_soon_expired_mandates")
     self.assertEqual(len(mail.outbox), 1)
     email = mail.outbox[0]
     self.assertEqual(email.subject,
                      settings.MANDAT_EXPIRED_SOON_EMAIL_SUBJECT)
     self.assertIn(self.aidant.email, email.recipients())
     self.assertNotIn(self.unrelated_aidant.email, email.recipients())
Пример #16
0
    def test_get_valid_autorisation_method(self):
        # A valid mandat with one revoked autorisation
        usager_charles = UsagerFactory(given_name="Charles", sub="Charles")
        active_mandat = MandatFactory(
            organisation=self.aidant_marge.organisation,
            usager=usager_charles,
        )
        valid_autorisation = AutorisationFactory(
            mandat=active_mandat,
            demarche="papiers",
            revocation_date=None,
        )
        AutorisationFactory(
            mandat=active_mandat,
            demarche="transport",
            revocation_date=timezone.now() - timedelta(days=1),
        )
        self.assertEqual(
            self.aidant_marge.get_valid_autorisation("papiers",
                                                     usager_charles),
            valid_autorisation,
        )
        self.assertEqual(
            self.aidant_marge.get_valid_autorisation("transport",
                                                     usager_charles), None)

        # An expired Mandat
        expired_mandat = MandatFactory(
            organisation=self.aidant_marge.organisation,
            usager=usager_charles,
            expiration_date=timezone.now() - timedelta(days=1),
        )
        AutorisationFactory(
            mandat=expired_mandat,
            demarche="social",
            revocation_date=None,
        )

        self.assertEqual(
            self.aidant_marge.get_valid_autorisation("social", usager_charles),
            None)
Пример #17
0
    def setUp(self):
        self.aidant = AidantFactory(email="*****@*****.**",
                                    post__with_otp_device=True)

        self.usager_josephine = UsagerFactory(given_name="Joséphine",
                                              family_name="ST-PIERRE")

        self.usager_anne = UsagerFactory(given_name="Anne Cécile Gertrude",
                                         family_name="EVALOUS")

        self.usager_corentin = UsagerFactory(given_name="Corentin",
                                             family_name="Dupont",
                                             preferred_username="******")

        self.url_parameters = urlencode({
            "state": 1234,
            "nonce": 1234,
            "response_type": "code",
            "client_id": settings.FC_AS_FI_ID,
            "redirect_uri": settings.FC_AS_FI_CALLBACK_URL,
            "scope": "openid profile email address phone birth",
            "acr_values": "eidas1",
        })

        MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_josephine,
            post__create_authorisations=["argent", "famille"],
        )

        MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_corentin,
            post__create_authorisations=["argent", "famille", "logement"],
        )

        MandatFactory(
            organisation=self.aidant.organisation,
            usager=self.usager_anne,
            post__create_authorisations=["argent", "famille", "logement"],
        )
    def setUpClass(cls):
        cls.aidant = AidantFactory()
        device = cls.aidant.staticdevice_set.create(id=cls.aidant.id)
        device.token_set.create(token="123456")

        cls.usager_josephine = UsagerFactory(given_name="Joséphine")
        cls.usager_corentin = UsagerFactory(given_name="Corentin")

        cls.mandat_aidant_josephine_6 = MandatFactory(
            organisation=cls.aidant.organisation,
            usager=cls.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        AutorisationFactory(
            mandat=cls.mandat_aidant_josephine_6,
            demarche="social",
        )

        cls.mandat_aidant_josephine_1 = MandatFactory(
            organisation=cls.aidant.organisation,
            usager=cls.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=1),
        )

        AutorisationFactory(
            mandat=cls.mandat_aidant_josephine_1,
            demarche="papiers",
        )

        cls.mandat_aidant_corentin_365 = MandatFactory(
            organisation=cls.aidant.organisation,
            usager=cls.usager_corentin,
            expiration_date=timezone.now() + timedelta(days=365),
        )
        AutorisationFactory(
            mandat=cls.mandat_aidant_corentin_365,
            demarche="famille",
        )

        super().setUpClass()
Пример #19
0
    def setUpTestData(cls):
        cls.client = Client()

        cls.our_organisation = OrganisationFactory()
        cls.our_aidant = AidantFactory(organisation=cls.our_organisation)
        cls.our_usager = UsagerFactory()

        cls.valid_mandat = MandatFactory(
            organisation=cls.our_organisation,
            usager=cls.our_usager,
        )
        cls.valid_autorisation = AutorisationFactory(
            mandat=cls.valid_mandat, demarche=[*settings.DEMARCHES][0])
Пример #20
0
    def test_know_error_cases(self):
        def error_case_tester(mandat_id):
            self.client.force_login(self.our_aidant)
            response = self.client.get(f"/mandats/{mandat_id}/cancel_confirm")
            url = "/espace-aidant/"
            self.assertRedirects(response, url, fetch_redirect_response=False)

        expired_mandat = MandatFactory(expiration_date=timezone.now() -
                                       timedelta(hours=6))
        revoked_mandat = MandatFactory()
        AutorisationFactory(mandat=revoked_mandat,
                            revocation_date=timezone.now() -
                            timedelta(hours=6))
        other_org = OrganisationFactory(name="not our organisation")
        unrelated_mandat = MandatFactory(organisation=other_org,
                                         usager=self.our_usager)
        non_existing_mandat_id = Mandat.objects.last().id + 1

        error_case_tester(non_existing_mandat_id)
        error_case_tester(expired_mandat.id)
        error_case_tester(revoked_mandat.id)
        error_case_tester(unrelated_mandat.id)
Пример #21
0
 def test_two_soon_expired_mandates_in_different_orgas(self):
     for _ in range(2):
         aidant = AidantFactory()
         MandatFactory(duree_keyword="LONG",
                       organisation=aidant.organisation)
     call_command("notify_soon_expired_mandates")
     self.assertEqual(len(mail.outbox), 2)
     first_email, second_email = mail.outbox
     self.assertNotEqual(first_email.recipients(),
                         second_email.recipients())
     self.assertNotIn(first_email.recipients()[0],
                      second_email.recipients())
     self.assertNotIn(second_email.recipients()[0],
                      first_email.recipients())
Пример #22
0
    def setUp(self):
        self.aidant_thierry = AidantFactory(email="*****@*****.**")
        device = self.aidant_thierry.staticdevice_set.create(id=self.aidant_thierry.id)
        device.token_set.create(token="123456")

        self.mandat = MandatFactory(organisation=self.aidant_thierry.organisation)
        AutorisationFactory(
            mandat=self.mandat,
            demarche="argent",
        )
        AutorisationFactory(
            mandat=self.mandat,
            demarche="famille",
        )
Пример #23
0
    def setUpClass(cls):
        cls.aidant_thierry = AidantFactory()
        device = cls.aidant_thierry.staticdevice_set.create(
            id=cls.aidant_thierry.id)
        device.token_set.create(token="123456")
        cls.aidant_jacqueline = AidantFactory(
            username="******",
            email="*****@*****.**",
            password="******",
            first_name="Jacqueline",
            last_name="Fremont",
        )
        cls.usager_josephine = UsagerFactory(given_name="Joséphine")
        cls.mandat_thierry_josephine = MandatFactory(
            organisation=cls.aidant_thierry.organisation,
            usager=cls.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        AutorisationFactory(
            mandat=cls.mandat_thierry_josephine,
            demarche="argent",
        )
        AutorisationFactory(
            mandat=cls.mandat_thierry_josephine,
            demarche="famille",
        )

        cls.mandat_jacqueline_josephine = MandatFactory(
            organisation=cls.aidant_jacqueline.organisation,
            usager=cls.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=12),
        )
        AutorisationFactory(
            mandat=cls.mandat_jacqueline_josephine,
            demarche="logement",
        )
        super().setUpClass()
Пример #24
0
 def test_no_renew_button_displayed_if_expired_over_a_year(self):
     over_a_year_expired_mandat = MandatFactory(
         organisation=self.aidant_thierry.organisation,
         usager=self.usager,
         expiration_date=timezone.now() - timedelta(days=365),
         post__create_authorisations=["argent", "famille", "logement"],
     )
     self.assertFalse(
         over_a_year_expired_mandat.is_active,
         "Generated mandat should not be active",
     )
     self.client.force_login(self.aidant_thierry)
     self.assertEqual(Mandat.objects.count(), 1)
     response = self.client.get(reverse("usagers"))
     self.assertNotContains(response, "Renouveler")
Пример #25
0
 def test_renew_mandat_ok(self):
     MandatFactory(
         organisation=self.aidant_thierry.organisation,
         usager=self.usager,
         expiration_date=timezone.now() + timedelta(days=5),
     )
     self.client.force_login(self.aidant_thierry)
     self.assertEqual(Mandat.objects.count(), 1)
     self.assertEqual(Connection.objects.count(), 0)
     data = {"demarche": ["papiers", "logement"], "duree": "SHORT"}
     response = self.client.post(reverse("renew_mandat",
                                         args=(self.usager.pk, )),
                                 data=data)
     self.assertRedirects(response, reverse("new_mandat_recap"))
     self.assertEqual(Connection.objects.count(), 1)
     self.assertEqual(Mandat.objects.count(), 1)
Пример #26
0
    def setUpTestData(cls):
        cls.client = Client()
        cls.usager = UsagerFactory(
            given_name="Joséphine",
            family_name="ST-PIERRE",
            preferred_username="******",
            birthdate=date(1969, 12, 25),
            gender=Usager.GENDER_FEMALE,
            birthplace="70447",
            birthcountry=Usager.BIRTHCOUNTRY_FRANCE,
            sub="test_sub",
            email="*****@*****.**",
            creation_date="2019-08-05T15:49:13.972Z",
            phone="0 800 840 800",
        )
        cls.aidant_thierry = AidantFactory()
        cls.mandat_thierry_usager = MandatFactory(
            organisation=cls.aidant_thierry.organisation,
            usager=cls.usager,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        cls.autorisation = AutorisationFactory(
            mandat=cls.mandat_thierry_usager,
            demarche="transports",
        )

        cls.access_token = "test_access_token"
        cls.access_token_hash = make_password(cls.access_token,
                                              settings.FC_AS_FI_HASH_SALT)
        cls.connection = Connection.objects.create(
            state="avalidstate123",
            code="test_code",
            nonce="avalidnonde456",
            usager=cls.usager,
            access_token=cls.access_token_hash,
            expires_on=datetime(2012,
                                1,
                                14,
                                3,
                                21,
                                34,
                                0,
                                tzinfo=pytz_timezone("Europe/Paris")),
            aidant=cls.aidant_thierry,
            organisation=cls.aidant_thierry.organisation,
            autorisation=cls.autorisation,
        )
Пример #27
0
    def setUp(self):
        self.aidant_1 = AidantFactory()
        device = self.aidant_1.staticdevice_set.create(id=self.aidant_1.id)
        device.token_set.create(token="123456")
        self.aidant_2 = AidantFactory(
            username="******",
            email="*****@*****.**",
            password="******",
            first_name="Jacqueline",
            last_name="Fremont",
        )
        self.usager_josephine = UsagerFactory(
            given_name="Joséphine", family_name="ST-PIERRE"
        )
        self.usager_anne = UsagerFactory(
            given_name="Anne Cécile Gertrude", family_name="EVALOUS"
        )

        mandat_aidant_1_jo_6 = MandatFactory(
            organisation=self.aidant_1.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        AutorisationFactory(
            mandat=mandat_aidant_1_jo_6, demarche="argent",
        )

        mandat_aidant_1_jo_12 = Mandat.objects.create(
            organisation=self.aidant_1.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=12),
        )

        AutorisationFactory(
            mandat=mandat_aidant_1_jo_12, demarche="famille",
        )

        mandat_aidant_2_jo_12 = Mandat.objects.create(
            organisation=self.aidant_2.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=12),
        )
        AutorisationFactory(
            mandat=mandat_aidant_2_jo_12, demarche="logement",
        )
Пример #28
0
    def setUpTestData(cls):
        cls.aidant = AidantFactory(username="******",
                                   email="*****@*****.**")
        device = cls.aidant.staticdevice_set.create(id=cls.aidant.id)
        device.token_set.create(token="123456")

        cls.usager_philomene = UsagerFactory(given_name="Philomène",
                                             family_name="Smith")

        cls.mandat_aidant_phillomene = MandatFactory(
            organisation=cls.aidant.organisation,
            usager=cls.usager_philomene,
            expiration_date=timezone.now() - timedelta(days=6),
        )
        AutorisationFactory(
            mandat=cls.mandat_aidant_phillomene,
            demarche="social",
        )
Пример #29
0
 def test_autorisation_expiration_date_setting(self):
     mandat = MandatFactory(
         organisation=self.aidant_marge.organisation,
         usager=self.usager_homer,
         expiration_date=timezone.now() + timedelta(days=3),
     )
     autorisation = AutorisationFactory(
         mandat=mandat,
         demarche="Carte grise",
     )
     self.assertEqual(
         autorisation.creation_date,
         datetime(2019, 1, 14, tzinfo=pytz_timezone("Europe/Paris")),
     )
     self.assertEqual(
         autorisation.mandat.expiration_date,
         datetime(2019, 1, 17, tzinfo=pytz_timezone("Europe/Paris")),
     )
Пример #30
0
    def setUp(self):
        self.aidant_1 = AidantFactory(email="*****@*****.**")
        device = self.aidant_1.staticdevice_set.create(id=self.aidant_1.id)
        device.token_set.create(token="123456")
        self.aidant_2 = AidantFactory()
        self.usager_josephine = UsagerFactory(given_name="Joséphine",
                                              family_name="ST-PIERRE")
        self.usager_anne = UsagerFactory(given_name="Anne Cécile Gertrude",
                                         family_name="EVALOUS")

        mandat_aidant_1_jo_6 = MandatFactory(
            organisation=self.aidant_1.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=6),
        )
        AutorisationFactory(
            mandat=mandat_aidant_1_jo_6,
            demarche="argent",
        )

        mandat_aidant_1_jo_12 = Mandat.objects.create(
            organisation=self.aidant_1.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=12),
        )

        AutorisationFactory(
            mandat=mandat_aidant_1_jo_12,
            demarche="famille",
        )

        mandat_aidant_2_jo_12 = Mandat.objects.create(
            organisation=self.aidant_2.organisation,
            usager=self.usager_josephine,
            expiration_date=timezone.now() + timedelta(days=12),
        )
        AutorisationFactory(
            mandat=mandat_aidant_2_jo_12,
            demarche="logement",
        )