Skip to content

Commit

Permalink
chore: test validation api champ etatProduction
Browse files Browse the repository at this point in the history
Signed-off-by: Maud Royer <[email protected]>
  • Loading branch information
jillro committed Jul 11, 2024
1 parent e48309b commit 5759c5e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
29 changes: 29 additions & 0 deletions lib/providers/__fixtures__/agence-bio-api-parcellaire.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,34 @@
]
}
]
},
{
"numeroBio": "77777",
"numeroClient": "100012",
"anneeReferenceControle": 2022,
"anneeAssolement": 2022,
"dateAudit": "2023-04-27",
"dateCertificationDebut": "2023-01-01",
"dateCertificationFin": "2025-03-31",
"numeroPacage": "084012821",
"commentaire": "notes d'audit",
"parcelles": [
{
"id": "45742",
"dateEngagement": "2023-04-27",
"etatProduction": "invalide",
"geom": "[[[4.8740990843182042,44.255949709765304],[4.8739614029301244,44.255016135661734],[4.8736532263747678,44.255001848456033],[4.8738004728368587,44.255928756333255],[4.8740990843182042,44.255949709765304]]]}",
"commentaire": "Parcelle 5 ILOT 12 PAC 2023 0C 1271",
"culture": [
{
"codeCPF": "01.92",
"dateSemis": "2023-10-10",
"variete": "",
"quantite": 25,
"unite": "%"
}
]
}
]
}
]
10 changes: 6 additions & 4 deletions server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1340,15 +1340,16 @@ describe('POST /api/v2/certification/parcelles', () => {
expect(res.status).toBe(400)
expect(mockSentry).not.toHaveBeenCalled()
expect(res.body).toEqual({
nbObjetTraites: 5,
nbObjetTraites: 6,
nbObjetAcceptes: 1,
nbObjetRefuses: 4,
nbObjetRefuses: 5,
listeProblemes: [
// in case of error, check `createOrUpdateOperatorRecord()` SQL arity
'[#2] champ dateAudit incorrect',
'[#3] champ geom incorrect : Expected \',\' or \']\' after array element in JSON at position 32635',
'[#4] Impossible de créer une parcelle sans donnée géographique.',
'[#5] Les dates de certification sont manquantes.'
'[#5] Les dates de certification sont manquantes.',
'[#6] champ etatProduction incorrect'
]
})
})
Expand All @@ -1360,6 +1361,7 @@ describe('POST /api/v2/certification/parcelles', () => {
validApiParcellaire[2].parcelles[0].geom = '[[[0,0],[0,1],[1,1],[1,0],[0,0]]]'
validApiParcellaire[3].dateCertificationDebut = '2023-01-01'
validApiParcellaire[3].dateCertificationFin = '2024-01-01'
validApiParcellaire[4].parcelles[0].etatProduction = 'AB'
const res = await request(app.server)
.post('/api/v2/certification/parcelles')
.set('Authorization', fakeOcToken)
Expand All @@ -1371,7 +1373,7 @@ describe('POST /api/v2/certification/parcelles', () => {
expect(db._clientRelease).toHaveBeenCalled()
expect(res.status).toBe(202)
expect(res.body).toEqual({
nbObjetTraites: 4
nbObjetTraites: 5
})
})

Expand Down

0 comments on commit 5759c5e

Please sign in to comment.