def setUp(self): self.organisation_1 = OrganisationFactory() self.aidant_1 = AidantFactory(username="******") self.usager_1 = UsagerFactory() self.mandat_1 = Mandat.objects.create( organisation=self.organisation_1, usager=self.usager_1, creation_date=timezone.now(), duree_keyword="SHORT", expiration_date=timezone.now() + timedelta(days=1), ) AutorisationFactory( mandat=self.mandat_1, demarche="justice", ) self.usager_2 = UsagerFactory(sub="anothersub") self.mandat_2 = Mandat.objects.create( organisation=self.organisation_1, usager=self.usager_2, creation_date=timezone.now(), duree_keyword="SHORT", expiration_date=timezone.now() + timedelta(days=1), ) AutorisationFactory( mandat=self.mandat_2, demarche="argent", ) AutorisationFactory( mandat=self.mandat_2, demarche="transport", )
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")
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"], )
def setUpTestData(cls): cls.aidant_marge = UserFactory(username="******") cls.aidant_patricia = UserFactory(username="******") cls.usager_homer = UsagerFactory(given_name="Homer", sub="123") cls.usager_ned = UsagerFactory(given_name="Ned", sub="1234") cls.usager_bart = UsagerFactory(given_name="Bart", sub="1235") Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_homer, demarche="Carte grise", expiration_date=timezone.now() - timedelta(days=6), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_homer, demarche="social", expiration_date=timezone.now() + timedelta(days=365), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_homer, demarche="Revenus", expiration_date=timezone.now() + timedelta(days=6), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_ned, demarche="Logement", expiration_date=timezone.now() - timedelta(days=6), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_ned, demarche="transports", expiration_date=timezone.now() + timedelta(days=6), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_ned, demarche="famille", expiration_date=timezone.now() + timedelta(days=6), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_ned, demarche="social", expiration_date=timezone.now() + timedelta(days=6), ) Mandat.objects.create( aidant=cls.aidant_marge, usager=cls.usager_ned, demarche="travail", expiration_date=timezone.now() + timedelta(days=6), )
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", )
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, }
def setUp(self): self.client = Client() self.organisation = OrganisationFactory() self.aidant_thierry = AidantFactory(organisation=self.organisation) device = self.aidant_thierry.staticdevice_set.create(id=1) device.token_set.create(token="123456") device.token_set.create(token="223456") self.aidant_monique = AidantFactory( first_name="Monique", username="******", organisation=self.organisation, ) device = self.aidant_monique.staticdevice_set.create(id=2) device.token_set.create(token="323456") self.organisation_nantes = OrganisationFactory(name="Association Aide'o'Web") self.aidant_marge = AidantFactory( first_name="Marge", username="******", organisation=self.organisation_nantes ) device = self.aidant_marge.staticdevice_set.create(id=3) device.token_set.create(token="423456") self.test_usager_sub = ( "46df505a40508b9fa620767c73dc1d7ad8c30f66fa6ae5ae963bf9cccc885e8dv1" ) self.test_usager = UsagerFactory( given_name="Fabrice", birthplace="95277", sub=self.test_usager_sub, )
def setUp(self): self.client = Client() self.aidant = AidantFactory() self.client.force_login(self.aidant) self.epoch_date = DATE.timestamp() self.connection = Connection.objects.create( demarches=["argent", "papiers"], duree_keyword="SHORT", state="test_state", connection_type="FS", nonce="test_nonce", id=1, expires_on=DATE + timedelta(minutes=5), aidant=self.aidant, organisation=self.aidant.organisation, ) Connection.objects.create( state="test_another_state", connection_type="FS", nonce="test_another_nonce", id=2, ) self.usager_sub_fc = "123" self.usager_sub = generate_sha256_hash( f"{self.usager_sub_fc}{settings.FC_AS_FI_HASH_SALT}".encode()) self.usager = UsagerFactory(given_name="Joséphine", sub=self.usager_sub)
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.client = Client() self.aidant = AidantFactory() self.usager = UsagerFactory() self.mandat = MandatFactory(organisation=self.aidant.organisation, usager=self.usager) AutorisationFactory(mandat=self.mandat)
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)
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", )
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), )
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", )
def setUpTestData(cls): cls.client = Client() cls.organisation = OrganisationFactory() cls.aidant_thierry = AidantFactory(organisation=cls.organisation) device = cls.aidant_thierry.staticdevice_set.create(id=1) device.token_set.create(token="123456") device.token_set.create(token="223456") cls.usager = UsagerFactory(given_name="Fabrice")
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.usager_sub_fc = "123" self.usager_sub = generate_sha256_hash( f"{self.usager_sub_fc}{settings.FC_AS_FI_HASH_SALT}".encode()) self.usager = UsagerFactory(given_name="Joséphine", sub=self.usager_sub) self.aidant = AidantFactory() self.connection = Connection.objects.create( access_token="mock_access_token", aidant=self.aidant, )
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 setUp(self): self.code = "test_code" self.code_hash = make_password(self.code, settings.FC_AS_FI_HASH_SALT) self.usager = UsagerFactory(given_name="Joséphine") self.usager.sub = "avalidsub789" self.usager.save() self.connection = Connection() self.connection.state = "avalidstate123" self.connection.code = self.code_hash self.connection.nonce = "avalidnonce456" self.connection.usager = self.usager self.connection.expires_on = datetime( 2012, 1, 14, 3, 21, 34, tzinfo=pytz_timezone("Europe/Paris")) self.connection.save() self.fc_request = { "grant_type": "authorization_code", "redirect_uri": "test_url.test_url", "client_id": "test_client_id", "client_secret": "test_client_secret", "code": self.code, }
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()
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", )
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])
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.client = Client() self.aidant_thierry = AidantFactory() device = self.aidant_thierry.staticdevice_set.create(id=1) device.token_set.create(token="123456") self.test_usager = UsagerFactory( given_name="Fabrice", birthplace="95277", sub="test_sub", ) self.mandat_builder = Connection.objects.create( demarches=["papiers", "logement"], duree_keyword="EUS_03_20", mandat_is_remote=True, usager=self.test_usager, )
def test_saving_and_retrieving_connection(self): first_connection = Connection() first_connection.state = "aZeRtY" first_connection.code = "ert" first_connection.nonce = "varg" first_connection.usager = UsagerFactory(given_name="Joséphine") first_connection.save() second_connection = Connection() second_connection.state = "QsDfG" second_connection.usager = UsagerFactory(given_name="Fabrice") second_connection.save() saved_items = Connection.objects.all() self.assertEqual(saved_items.count(), 2) first_saved_item = saved_items[0] second_saved_item = saved_items[1] self.assertEqual(first_saved_item.state, "aZeRtY") self.assertEqual(first_saved_item.nonce, "varg") self.assertEqual(first_saved_item.usager.given_name, "Joséphine") self.assertEqual(second_saved_item.state, "QsDfG") self.assertEqual(second_saved_item.usager.gender, Usager.GENDER_MALE)
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, )
def setUpTestData(cls): cls.usager_sub_fc = "123" cls.usager_sub = generate_sha256_hash( f"{cls.usager_sub_fc}{settings.FC_AS_FI_HASH_SALT}".encode()) cls.usager = UsagerFactory(given_name="Joséphine", sub=cls.usager_sub) cls.aidant = AidantFactory() cls.connection = Connection.objects.create( access_token="mock_access_token", aidant=cls.aidant, organisation=cls.aidant.organisation, ) cls.connection_with_phone = Connection.objects.create( access_token="mock_access_token_with_phone", aidant=cls.aidant, organisation=cls.aidant.organisation, user_phone="0 800 840 800", )
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", )
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", )
def setUpTestData(cls): cls.atac_user = AidantFactory( is_staff=True, is_superuser=True, ) cls.atac_user.set_password("password") cls.atac_user.save() cls.atac_device = StaticDevice.objects.create(user=cls.atac_user, name="Device") cls.usager = UsagerFactory() cls.atac_client = Client() cls.atac_client.force_login(cls.atac_user) atac_session = cls.atac_client.session atac_session[DEVICE_ID_SESSION_KEY] = cls.atac_device.persistent_id atac_session.save() url_root = f"admin:{Journal._meta.app_label}_{Usager.__name__.lower()}" cls.url_root = url_root