Exemplo n.º 1
0
 def create_new_bank_informations(self,
                                  application_details: ApplicationDetail,
                                  venue_id: int) -> BankInformations:
     new_bank_informations = BankInformations()
     new_bank_informations.application_id = application_details.application_id
     new_bank_informations.venue_id = venue_id
     new_bank_informations.status = application_details.status
     new_bank_informations.date_modified = application_details.modification_date
     if application_details.status == BankInformationStatus.ACCEPTED:
         new_bank_informations.iban = application_details.iban
         new_bank_informations.bic = application_details.bic
     else:
         new_bank_informations.iban = None
         new_bank_informations.bic = None
     return new_bank_informations
Exemplo n.º 2
0
    def test_should_create_bank_informations_on_save_when_bank_informations_does_not_exist(
            self, app):
        # given
        offerer = create_offerer()
        repository.save(offerer)
        bank_informations_to_save = BankInformations(
            offerer_id=offerer.id,
            status=BankInformationStatus.ACCEPTED,
            application_id=8,
            iban="FR7630006000011234567890189",
            bic="QSDFGH8Z555",
        )

        # when
        bank_informations_saved = self.bank_informations_sql_repository.save(
            bank_informations_to_save)

        # then
        assert BankInformationsSQLEntity.query.count() == 1

        sql_bank_informations_saved = BankInformationsSQLEntity.query.first()
        assert sql_bank_informations_saved.offererId == offerer.id
        assert sql_bank_informations_saved.venueId is None
        assert sql_bank_informations_saved.iban == bank_informations_to_save.iban
        assert sql_bank_informations_saved.bic == bank_informations_to_save.bic
        assert sql_bank_informations_saved.applicationId == bank_informations_to_save.application_id
        assert sql_bank_informations_saved.status == bank_informations_to_save.status
        assert sql_bank_informations_saved.dateModified is not None

        assert bank_informations_saved.iban == bank_informations_to_save.iban
        assert bank_informations_saved.bic == bank_informations_to_save.bic
 def create_new_bank_informations(self,
                                  application_details: ApplicationDetail,
                                  offerer_id: str) -> BankInformations:
     new_bank_informations = BankInformations()
     new_bank_informations.application_id = application_details.application_id
     new_bank_informations.offerer_id = offerer_id
     new_bank_informations.status = application_details.status
     if application_details.status == BankInformationStatus.ACCEPTED:
         new_bank_informations.iban = application_details.iban
         new_bank_informations.bic = application_details.bic
     else:
         new_bank_informations.iban = None
         new_bank_informations.bic = None
     return new_bank_informations
def to_domain(bank_informations_sql_entity: BankInformationsSQLEntity) -> BankInformations:

    return BankInformations(
        application_id=bank_informations_sql_entity.applicationId,
        status=bank_informations_sql_entity.status,
        iban=bank_informations_sql_entity.iban,
        bic=bank_informations_sql_entity.bic,
        date_modified=bank_informations_sql_entity.dateModified,
    )
Exemplo n.º 5
0
    def test_should_not_create_bank_informations_on_save_when_no_offerer_associated_in_database(
            self, app):
        # given
        bank_informations_to_save = BankInformations(offerer_id=9,
                                                     status="ACCEPTED",
                                                     application_id=8)

        # when
        with pytest.raises(ApiErrors) as error:
            self.bank_informations_sql_repository.save(
                bank_informations_to_save)

        # then
        assert BankInformationsSQLEntity.query.count() == 0
        assert error.value.errors["offererId"] == [
            "Aucun objet ne correspond \u00e0 cet identifiant dans notre base de donn\u00e9es"
        ]
Exemplo n.º 6
0
    def test_should_not_update_bank_informations_when_bank_informations_do_not_exist_for_venue(
            self, app):
        # given
        bank_informations_to_save = BankInformations(
            status=BankInformationStatus.ACCEPTED,
            application_id=9,
            iban="FR7630006000011234567890189",
            bic="QSDFGH8Z555",
            venue_id=1,
        )

        # when
        bank_informations_updated = self.bank_informations_sql_repository.update_by_venue_id(
            bank_informations_to_save)

        # then
        assert BankInformationsSQLEntity.query.count() == 0
        assert bank_informations_updated is None
Exemplo n.º 7
0
    def test_should_not_create_bank_informations_on_save_when_bank_infos_is_already_associated_to_an_offerer_in_database(
            self, app):
        # given
        offerer = create_offerer()
        bank_informations = create_bank_information(offerer=offerer)
        repository.save(bank_informations)
        bank_informations_to_save = BankInformations(offerer_id=offerer.id,
                                                     status="ACCEPTED",
                                                     application_id=8)

        # when
        with pytest.raises(ApiErrors) as error:
            self.bank_informations_sql_repository.save(
                bank_informations_to_save)

        # then
        assert BankInformationsSQLEntity.query.count() == 1
        assert error.value.errors['"offererId"'] == [
            "Une entrée avec cet identifiant existe déjà dans notre base de données"
        ]
Exemplo n.º 8
0
    def test_should_update_bank_informations_when_bank_informations_already_exist_for_venue(
            self, app):
        # given
        offerer = create_offerer()
        venue = create_venue(offerer=offerer)
        bank_informations_sql = create_bank_information(
            venue=venue,
            application_id=9,
            status=BankInformationStatus.DRAFT,
            iban=None,
            bic=None)
        repository.save(bank_informations_sql)

        bank_informations_to_save = BankInformations(
            status=BankInformationStatus.ACCEPTED,
            application_id=9,
            iban="FR7630006000011234567890189",
            bic="QSDFGH8Z555",
            venue_id=venue.id,
            date_modified=datetime(2018, 2, 3),
        )

        # when
        bank_informations_saved = self.bank_informations_sql_repository.update_by_venue_id(
            bank_informations_to_save)

        # then
        assert BankInformationsSQLEntity.query.count() == 1

        sql_bank_informations_saved = BankInformationsSQLEntity.query.first()
        assert sql_bank_informations_saved.offererId == None
        assert sql_bank_informations_saved.venueId == venue.id
        assert sql_bank_informations_saved.iban == bank_informations_to_save.iban
        assert sql_bank_informations_saved.bic == bank_informations_to_save.bic
        assert sql_bank_informations_saved.applicationId == bank_informations_to_save.application_id
        assert sql_bank_informations_saved.status == bank_informations_to_save.status
        assert sql_bank_informations_saved.dateModified == bank_informations_to_save.date_modified

        assert bank_informations_saved.iban == bank_informations_to_save.iban
        assert bank_informations_saved.bic == bank_informations_to_save.bic