handle axione erreur
This commit is contained in:
parent
8c7ff6a11b
commit
68434bf446
8 changed files with 142 additions and 19 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
/elig-test.ini
|
/elig-test.ini
|
||||||
|
.vscode
|
|
@ -90,7 +90,6 @@ def query_axione(cfg, body):
|
||||||
print(headers)
|
print(headers)
|
||||||
print("BODY: ")
|
print("BODY: ")
|
||||||
print(body)
|
print(body)
|
||||||
print("===================")
|
|
||||||
with open("./fixtures/dummy-data-1.xml", "r") as f:
|
with open("./fixtures/dummy-data-1.xml", "r") as f:
|
||||||
dummyData = f.read()
|
dummyData = f.read()
|
||||||
return dummyData
|
return dummyData
|
||||||
|
@ -121,17 +120,45 @@ class BatimentResult(TypedDict):
|
||||||
referenceBatiment: str
|
referenceBatiment: str
|
||||||
etages: list[EtageResult]
|
etages: list[EtageResult]
|
||||||
|
|
||||||
|
class AxioneErreur(TypedDict):
|
||||||
|
codeErreur: str
|
||||||
|
libelleErreur: str
|
||||||
|
|
||||||
def parse_response(resp_str) -> list[BatimentResult]:
|
class AxioneResult(TypedDict):
|
||||||
|
codeRetour: int
|
||||||
|
axioneErreur: AxioneErreur
|
||||||
|
batiments: list[BatimentResult]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_response(resp_str) -> AxioneResult:
|
||||||
root = ET.fromstring(resp_str)
|
root = ET.fromstring(resp_str)
|
||||||
parsedBatiments = [
|
codeRetourXml = root.find(
|
||||||
parse_batiment(b)
|
".//{http://structureadresseftth.axione.fr/model/commun}codeRetour"
|
||||||
for b in root.findall(
|
)
|
||||||
".//{http://structureadresseftth.axione.fr/model/commun}batiment"
|
codeRetour = int(codeRetourXml.text.strip())
|
||||||
)
|
axioneErreur = None
|
||||||
]
|
parsedBatiments = []
|
||||||
return parsedBatiments
|
if codeRetour == 0:
|
||||||
|
parsedBatiments = [
|
||||||
|
parse_batiment(b)
|
||||||
|
for b in root.findall(
|
||||||
|
".//{http://structureadresseftth.axione.fr/model/commun}batiment"
|
||||||
|
)
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
axioneErreur = AxioneErreur(
|
||||||
|
codeErreur = root.find(
|
||||||
|
".//{http://structureadresseftth.axione.fr/model/commun}codeErreur"
|
||||||
|
).text.strip(),
|
||||||
|
libelleErreur = root.find(
|
||||||
|
".//{http://structureadresseftth.axione.fr/model/commun}libelleErreur"
|
||||||
|
).text.strip()
|
||||||
|
)
|
||||||
|
return AxioneResult(
|
||||||
|
codeRetour=codeRetour,
|
||||||
|
axioneErreur=axioneErreur,
|
||||||
|
batiments=parsedBatiments
|
||||||
|
)
|
||||||
|
|
||||||
def parse_batiment(batiment) -> BatimentResult:
|
def parse_batiment(batiment) -> BatimentResult:
|
||||||
etatBatiment = batiment.get("etatBatiment", None)
|
etatBatiment = batiment.get("etatBatiment", None)
|
||||||
|
|
46
fixtures/dummy-data-2.xml
Normal file
46
fixtures/dummy-data-2.xml
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
|
<SOAP-ENV:Header />
|
||||||
|
<SOAP-ENV:Body>
|
||||||
|
<ns3:obtentionStructureAdresseReponseSoap xmlns:ns2="http://structureadresseftth.axione.fr/model/commun" xmlns:ns3="http://structureadresseftth.axione.fr/model/entreprise">
|
||||||
|
<ns3:entete horodatageReponse="2022-02-13T00:57:50.773+01:00" horodatageRequete="2022-02-12T23:57:48.974060Z" identifiantReponse="1644710270773" versionWS="3.0">
|
||||||
|
<ns2:operateurCommercial identifiant="" nom="AQUILENET" />
|
||||||
|
</ns3:entete>
|
||||||
|
<ns3:codeRetour>
|
||||||
|
<ns2:codeRetour>0</ns2:codeRetour>
|
||||||
|
</ns3:codeRetour>
|
||||||
|
<ns3:codeOI>BEFO</ns3:codeOI>
|
||||||
|
<ns3:etatImmeuble>true</ns3:etatImmeuble>
|
||||||
|
<ns3:structureDetaillee>
|
||||||
|
<ns2:adresse referenceHexacle="361992226N">
|
||||||
|
<ns2:referenceRivoli codeInsee="36199" codeRivoli="0031" numeroVoie="48" />
|
||||||
|
</ns2:adresse>
|
||||||
|
<ns2:batiment conditionsSyndic="false" dateDebutAcceptationCmdAcces="2021-09-14T00:00:00.000+02:00" dateDebutFournitureCRCmdAcces="2021-09-14T00:00:00.000+02:00" etatBatiment="COMMERCIALISABLE" identifiantImmeuble="BAT36-7C32FE6AD11F4A6797E4F29E" nombreLogementsImmeuble="1" referenceBatiment="NA">
|
||||||
|
<ns2:referenceGeographique coordonneeImmeubleX="2.027143270510003" coordonneeImmeubleY="47.01243491007431" typeProjection="WGS84" />
|
||||||
|
<ns2:escalier reference="NA">
|
||||||
|
<ns2:etage nombreLignesActives="0" nombreLignesExistantes="0" nombreLocauxFTTH="1" refPriseCommandeObligatoire="false" reference="RDC">
|
||||||
|
<ns2:listePbo>
|
||||||
|
<ns2:pbo referencePBO="PBO36_ISS1_139" typePbo="AERIEN" />
|
||||||
|
</ns2:listePbo>
|
||||||
|
<ns2:listeLignesFTTH>
|
||||||
|
<ns2:ligneFTTH>
|
||||||
|
<ns2:prise etiquetteAPoser="Non" referencePBO="PBO36_ISS1_139">
|
||||||
|
<ns2:referencePTO>BF-ISS1-0110</ns2:referencePTO>
|
||||||
|
<ns2:referencePrisePromoteur />
|
||||||
|
<ns2:statutLigneFTTH actif="false" commercialisable="true" existant="false" raccordable="true" rompu="false" />
|
||||||
|
</ns2:prise>
|
||||||
|
</ns2:ligneFTTH>
|
||||||
|
<ns2:ligneFTTH>
|
||||||
|
<ns2:local localisationLocalOC="" localisationLocalOI="" />
|
||||||
|
</ns2:ligneFTTH>
|
||||||
|
</ns2:listeLignesFTTH>
|
||||||
|
<ns2:pm referencePM="ADR_36199_ISS1" referencePMT="PMT_36199_ISS1">
|
||||||
|
<ns2:typeEmplacementPM>PME</ns2:typeEmplacementPM>
|
||||||
|
<ns2:responsableBrassage>OC</ns2:responsableBrassage>
|
||||||
|
</ns2:pm>
|
||||||
|
</ns2:etage>
|
||||||
|
</ns2:escalier>
|
||||||
|
</ns2:batiment>
|
||||||
|
</ns3:structureDetaillee>
|
||||||
|
</ns3:obtentionStructureAdresseReponseSoap>
|
||||||
|
</SOAP-ENV:Body>
|
||||||
|
</SOAP-ENV:Envelope>
|
36
fixtures/dummy-data-3.xml
Normal file
36
fixtures/dummy-data-3.xml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
|
<SOAP-ENV:Header />
|
||||||
|
<SOAP-ENV:Body>
|
||||||
|
<ns3:obtentionStructureAdresseReponseSoap xmlns:ns2="http://structureadresseftth.axione.fr/model/commun" xmlns:ns3="http://structureadresseftth.axione.fr/model/entreprise">
|
||||||
|
<ns3:entete horodatageReponse="2022-02-13T00:55:44.339+01:00" horodatageRequete="2022-02-12T23:55:42.382844Z" identifiantReponse="1644710144339" versionWS="3.0">
|
||||||
|
<ns2:operateurCommercial identifiant="" nom="AQUILENET" />
|
||||||
|
</ns3:entete>
|
||||||
|
<ns3:codeRetour>
|
||||||
|
<ns2:codeRetour>1</ns2:codeRetour>
|
||||||
|
<ns2:codeErreur>I01</ns2:codeErreur>
|
||||||
|
<ns2:libelleErreur>Code Rivoli introuvable, manquant ou incomplet</ns2:libelleErreur>
|
||||||
|
</ns3:codeRetour>
|
||||||
|
<ns3:codeOI />
|
||||||
|
<ns3:structureDetaillee>
|
||||||
|
<ns2:adresse />
|
||||||
|
<ns2:batiment referenceBatiment="">
|
||||||
|
<ns2:referenceGeographique coordonneeImmeubleX="" coordonneeImmeubleY="" typeProjection="" />
|
||||||
|
<ns2:escalier reference="">
|
||||||
|
<ns2:etage refPriseCommandeObligatoire="false" reference="">
|
||||||
|
<ns2:listePbo>
|
||||||
|
<ns2:pbo referencePBO="" typePbo="" typeRaccoPbPTO="" />
|
||||||
|
</ns2:listePbo>
|
||||||
|
<ns2:listeLignesFTTH>
|
||||||
|
<ns2:ligneFTTH />
|
||||||
|
</ns2:listeLignesFTTH>
|
||||||
|
<ns2:pm referencePM="" referencePMT="">
|
||||||
|
<ns2:typeEmplacementPM>PME</ns2:typeEmplacementPM>
|
||||||
|
<ns2:responsableBrassage>OI</ns2:responsableBrassage>
|
||||||
|
</ns2:pm>
|
||||||
|
</ns2:etage>
|
||||||
|
</ns2:escalier>
|
||||||
|
</ns2:batiment>
|
||||||
|
</ns3:structureDetaillee>
|
||||||
|
</ns3:obtentionStructureAdresseReponseSoap>
|
||||||
|
</SOAP-ENV:Body>
|
||||||
|
</SOAP-ENV:Envelope>
|
|
@ -7,8 +7,8 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
|
||||||
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
|
||||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
|
|
|
@ -11,11 +11,12 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1 id="aquilenet-title">Aquilenet</h1>
|
<h1 class="text-center" id="aquilenet-title">Aquilenet</h1>
|
||||||
<div id="container">
|
{% if result['codeRetour'] == 0 %}
|
||||||
|
<div id="containerResults" class="container">
|
||||||
<h1 id="main-title">Test d'Éligibilité FTTH Aquilenet: Résultats</h1>
|
<h1 id="main-title">Test d'Éligibilité FTTH Aquilenet: Résultats</h1>
|
||||||
<p>Résultat pour le PTO: {{ pto }}</p>
|
<p>Résultat pour le PTO: {{ pto }}</p>
|
||||||
{% for batiment in result %}
|
{% for batiment in result['batiments'] %}
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -58,5 +59,12 @@
|
||||||
</table>
|
</table>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div id="containerResults" class="container">
|
||||||
|
<h1 id="main-title">Erreur</h1>
|
||||||
|
<p>Code d'erreur: {{ result['axioneErreur']['codeErreur'] }}</p>
|
||||||
|
<p>Description de l'erreur: {{ result['axioneErreur']['libelleErreur'] }}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -93,7 +93,7 @@ form {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
table,td {
|
table,td {
|
||||||
border: 2px solid #333;
|
border: 2px solid #333;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
@ -107,4 +107,4 @@ thead, tfoot {
|
||||||
td {
|
td {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
} */
|
}
|
||||||
|
|
|
@ -58,7 +58,12 @@ def test_address():
|
||||||
numeroVoie = escape(request.form['numeroVoie'])
|
numeroVoie = escape(request.form['numeroVoie'])
|
||||||
# Trimming rivoli's key
|
# Trimming rivoli's key
|
||||||
codeRivoli = escape(request.form['codeRivoli'])[:-1]
|
codeRivoli = escape(request.form['codeRivoli'])[:-1]
|
||||||
result = query_axione_fantoir(cfg, codeInsee, codeRivoli, numeroVoie)
|
result = parse_response(query_axione_fantoir(cfg, codeInsee, codeRivoli, numeroVoie))
|
||||||
|
if cfg.debug:
|
||||||
|
print("===================")
|
||||||
|
print("Dummy response: ")
|
||||||
|
print(result)
|
||||||
|
print("===================")
|
||||||
return render_template("result.html", pto="", result=result)
|
return render_template("result.html", pto="", result=result)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue