Skip to content

Commit

Permalink
correct and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Dec 11, 2023
1 parent 863e76f commit 3b30fd4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
2 changes: 2 additions & 0 deletions lib/validate/__tests__/1.4/data/1.4-bad-dependance-id-ban.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cle_interop;id_ban_commune;id_ban_toponyme;id_ban_adresse;commune_insee;voie_nom;numero;suffixe;commune_nom;position;long;lat;x;y;source;date_der_maj
31591_xxxx_00009;;8a3bab10-f329-4ce3-9c7d-280d91a8053a;3c87abe4-887b-46ee-9192-5c1b35a06625;31591;Rue des 3 Places;9;;Escoulis;entrée;1.028392;43.111637;539416.13;6225601.11;;2020-11-09
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cle_interop;id_ban_commune;id_ban_toponyme;id_ban_adresse;commune_insee;voie_nom;numero;suffixe;commune_nom;position;long;lat;x;y;source;date_der_maj
31591_xxxx_00009;0246e48c-f33d-433a-8984-034219be842e;8a3bab10-f329-4ce3-9c7d-280d91a8053a;;31591;Rue des 3 Places;9;;Escoulis;entrée;1.028392;43.111637;539416.13;6225601.11;;2020-11-09
47 changes: 35 additions & 12 deletions lib/validate/__tests__/1.4/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ test('Error bad id ban adresses (file 1.4)', async t => {

t.is(report.encoding, 'utf-8')
t.is(report.parseOk, true)
t.is(report.profilesValidation[1.4].isValid, true)
t.is(report.profilesValidation['1.4-relax'].isValid, true)
t.is(report.profilesValidation[1.4].isValid, false)
t.is(report.profilesValidation['1.4-relax'].isValid, false)

const error = report.profilErrors.filter(e => e.code === 'id_ban_adresse.type_invalide')
t.is(error.length, 1)
t.is(error[0].level, 'W')
t.is(error[0].level, 'E')
})

test('Error bad id ban commune (file 1.4)', async t => {
Expand All @@ -89,12 +89,12 @@ test('Error bad id ban commune (file 1.4)', async t => {

t.is(report.encoding, 'utf-8')
t.is(report.parseOk, true)
t.is(report.profilesValidation[1.4].isValid, true)
t.is(report.profilesValidation['1.4-relax'].isValid, true)
t.is(report.profilesValidation[1.4].isValid, false)
t.is(report.profilesValidation['1.4-relax'].isValid, false)

const error = report.profilErrors.filter(e => e.code === 'id_ban_commune.type_invalide')
t.is(error.length, 1)
t.is(error[0].level, 'W')
t.is(error[0].level, 'E')
})

test('Error bad id ban toponyme a (file 1.4)', async t => {
Expand All @@ -103,12 +103,12 @@ test('Error bad id ban toponyme a (file 1.4)', async t => {

t.is(report.encoding, 'utf-8')
t.is(report.parseOk, true)
t.is(report.profilesValidation[1.4].isValid, true)
t.is(report.profilesValidation['1.4-relax'].isValid, true)
t.is(report.profilesValidation[1.4].isValid, false)
t.is(report.profilesValidation['1.4-relax'].isValid, false)

const error = report.profilErrors.filter(e => e.code === 'id_ban_toponyme.type_invalide')
t.is(error.length, 1)
t.is(error[0].level, 'W')
t.is(error[0].level, 'E')
})

test('Error incoherent ban id (file 1.4)', async t => {
Expand All @@ -117,11 +117,34 @@ test('Error incoherent ban id (file 1.4)', async t => {

t.is(report.encoding, 'utf-8')
t.is(report.parseOk, true)
t.is(report.profilesValidation[1.4].isValid, true)
t.is(report.profilesValidation['1.4-relax'].isValid, true)
t.is(report.profilesValidation[1.4].isValid, false)
t.is(report.profilesValidation['1.4-relax'].isValid, false)

const error = report.profilErrors.filter(e => e.code === 'row.incoherence_ids_ban')
t.is(error.length, 1)
t.is(error[0].level, 'W')
t.is(error[0].level, 'E')
})

test('Good incoherent dependance ban id (file 1.4)', async t => {
const buffer = await readAsBuffer('1.4-good-dependance-id-ban.csv')
const report = await validate(buffer)

t.is(report.encoding, 'utf-8')
t.is(report.parseOk, true)
t.is(report.profilesValidation[1.4].isValid, true)
t.is(report.profilesValidation['1.4-relax'].isValid, true)
})

test('Error incoherent dependance ban id (file 1.4)', async t => {
const buffer = await readAsBuffer('1.4-bad-dependance-id-ban.csv')
const report = await validate(buffer)

t.is(report.encoding, 'utf-8')
t.is(report.parseOk, true)
t.is(report.profilesValidation[1.4].isValid, false)
t.is(report.profilesValidation['1.4-relax'].isValid, false)

const error = report.profilErrors.filter(e => e.code === 'row.incoherence_dependance_ids_ban')
t.is(error.length, 1)
t.is(error[0].level, 'E')
})

0 comments on commit 3b30fd4

Please sign in to comment.