Skip to content

Commit

Permalink
✅ Add tests exception
Browse files Browse the repository at this point in the history
  • Loading branch information
LePetitTim committed Apr 25, 2023
1 parent 26cf900 commit cd6d449
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions project/geosource/tests/data/source_empty.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XCOORD;YCOORD;ID;numeroVoieEtablissement;indiceRepetitionEtablissement;typeVoieEtablissement;libelleVoieEtablissement;codePostalEtablissement;CodeINSEECommuneEtablissement;LibelleCommuneEtablissement;photoEtablissement;Siret;denominationUsuelleEtablisemment2017;denominationUsuelleEtablissment2019;changementEnseigne;Vacance;commerceInfoType;commerceInfoPersoSalarie;commerceInfoPersoDirigeant;commerceInfoPersoConjoint;codeape;Activitedetaillee;ENSEIGNE_1;statutens;nomenclature;Nomencla_1;commerceInfoArtisanat;commerceInfoCA;commerceLocalSurfacevente;commerceLocalSurfacereserve;commerceLocalSurfaceTotal;commerceLocalVitrine;commerceLocalFacade;commerceLocalTravauxfacade;commerceLocalTravauxamenagement;commerceLocalEquipement;commerceLocalEtage;commerceLocalEntree;commerceLocalCommoditeSanitaire;commerceLocalCommoditeSanitaireEtage;commerceLocalCommoditeSanitaireClient;commerceLocalCommoditeCuisine;commerceLocalCommoditeCuisineEtage;commerceLocalPMR;commerceLocalPMRDerogation;commerceLocalLivraison;commerceLocalLivraisonMode;commerceLocalParkingEmploye;commerceLocalParkingChaland;commerceLocalTerrasse;commerceLocalTerrassePlace;commerceLocalFibreoptique;commerceLocalDechetType;commerceLocalDechetLocal;commerceLocalDechetCollecte;commerceLocalConteneur;commerceLocalAdapte;commerceLocalRecherche;commerceLocalCommentaire;commerceNoteBati;commerceNoteDevanture;commerceNoteVitrine;commerceNoteAccesetages;commerceNoteAccessibilite;commerceNoteMoyenne;commercantProprietaire;commercantIdentite;commercantIdentiteMail;commercantIdentiteTel;commercantAdresseNum;indiceRepetitionEtablissement;commercantAdresseTypevoie;commercantAdresseLibvoie;commercantAdresseCodepostal;commercantAdresseCommune;commercantanneenaissance;commercantStatut;commercantCessionFonds;commercantCessionLocal;commercantProjetentreprise;proprietaireNomSCI;proprietaireIdentite;proprietaireIdentiteMail;proprietaireIdentiteTel;proprietaireAdresseNum;proprietaireindicerep;proprietaireAdresseTypevoie;proprietaireAdresseLibvoie;proprietaireAdresseCodePostal;proprietaireAdresseCommune;proprietaireanneenaissance;proprietaireStatut;proprietaireCessionFonds;proprietaireCessionocal;proprietairProjetreprise;bailProprietairePrixAchat;bailProprietaireAnneeAchat;bailProprietairePasdeporte;bailProprietairePrixvente;bailProprietaireTravaux;bailProprietaireTravauxNature;bailProprietaireTravauxEcheance;bailLocataireBailType;bailLocataireBailDuree;bailLocataireBailFin;bailLocataireLoyer;bailLocationValeurlocative;bailLocataireLoyerCharges;bailLocataireLoyerTaxeFonciere;bailLocataireLoyerTaxefonciere;bailLocatairePasdeporte;bailLocataireDroitaubail;bailLocataireFondsdecommerce;vacanceCommerceSurfacevente;vacanceCommerceSurfacereserve;vacanceCommerceLineaire;vacanceCommerceActivite;vacanceCommerceDate;vacanceCommercePrixvente;vacanceCommerceLoyer;vacanceCommerceCharges;vacanceCommerceDateproposition;vacanceCommerceVisite;vacanceCommerceCommentaire;vacanceAgenceNom;vacanceAgenceAdresseNum;vacanceAgenceAdresseIndice;vacanceAgenceAdresseTypevoie;vacanceAgenceAdresseLibvoie;vacanceAdresseCodepostal;vacanceAgenceAdresseCommune;vacanceContactIdentite;vacanceContactIdentiteMail;vacanceContactIdentiteTel;vacanceContactAdresseNum;vacanceContactAdresseIndice;vacanceContactTypevoie;vacanceContactLibvoie;vacanceContactCodePostal;vacanceContactCommune;quotechar
20 changes: 20 additions & 0 deletions project/geosource/tests/test_model_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ def test_coordinates_systems_malformed_raise_index_error(
with self.assertRaises(IndexError):
source._get_records()

def test_source_empty_csv(self, mocked_es_delete, mocked_es_create):
source = CSVSource.objects.create(
file=get_file("source_empty.csv"),
geom_type=0,
id_field="ID",
settings={
"encoding": "UTF-8",
"coordinate_reference_system": "EPSG_4326", # Wrong on purpose
"char_delimiter": "doublequote",
"field_separator": "semicolon",
"decimal_separator": "point",
"use_header": True,
"coordinates_field": "two_columns",
"longitude_field": "XCOORD",
"latitude_field": "YCOORD",
},
)
with self.assertRaisesRegex(Exception, "Failed to refresh data"):
source.refresh_data()

def test_invalid_id_field_report_message_when_refreshing_data(
self, mocked_es_delete, mocked_es_create
):
Expand Down

0 comments on commit cd6d449

Please sign in to comment.