This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cron): traitement errone (#258)
* feat(cron): traitement errone * chore: up * chore: up * chore: up * fix: up * fix: up * fix: add cron
- Loading branch information
1 parent
70325e8
commit 4ab79b9
Showing
5 changed files
with
427 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
.kube-workflow/prod/templates/reportingTraitementErrone.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
namespace: mon-psy-sante | ||
name: reporting-traitement-errone | ||
labels: | ||
app: mon-psy | ||
spec: | ||
schedule: "0 11 * * 2" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: mon-psy | ||
image: ghcr.io/socialgouv/mon-psy-sante/app:{{ .Values.global.imageTag }} | ||
envFrom: | ||
- secretRef: | ||
name: app-sealed-secret | ||
- secretRef: | ||
name: pg-user | ||
command: | ||
- yarn | ||
- run | ||
- cron:launch | ||
- reportingTraitementErrone | ||
restartPolicy: Never | ||
concurrencyPolicy: Forbid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
import { | ||
cpamOnly, | ||
notificationSelectionNotChecked, | ||
withoutInstructeurFB, | ||
} from "../../cron/reportingTraitementErrone"; | ||
import { request } from "../../services/demarchesSimplifiees/request"; | ||
import { DSPsychologist } from "../../types/psychologist"; | ||
|
||
const INSTRUCTEUR_FB = "SW5zdHJ1Y3RldXItNjQzNjI="; | ||
const DOSSIER_ELIGIBLE = "Q2hhbXAtMTg0NDM5NQ=="; | ||
const NOTIFICATION_SELECTION = "Q2hhbXAtMjMyMzA2Mg=="; | ||
|
||
jest.mock("../../services/demarchesSimplifiees/request"); | ||
|
||
describe("Cron import from DS", () => { | ||
function mockDSCall(psychologistsInDS: Partial<DSPsychologist>[]) { | ||
const mockRequest = <jest.Mock>request; | ||
mockRequest.mockImplementationOnce(() => | ||
Promise.resolve({ | ||
demarche: { dossiers: { nodes: psychologistsInDS, pageInfo: {} } }, | ||
}) | ||
); | ||
} | ||
|
||
describe("`cpamOnly()`: dossiers en construction with only CPAM instructeurs", () => { | ||
it("should filter out dossiers with no instructeurs", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
instructeurs: [], | ||
}, | ||
]); | ||
expect(await cpamOnly()).toHaveLength(0); | ||
}); | ||
|
||
it("should filter out dossiers with internal instructeurs and no CPAM instructeurs", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
instructeurs: [ | ||
{ id: "SW5zdHJ1Y3RldXItNjExNTM=", email: "x@example.org" }, | ||
{ id: "SW5zdHJ1Y3RldXItNDk3NDI=", email: "y@example.org" }, | ||
], | ||
}, | ||
]); | ||
expect(await cpamOnly()).toHaveLength(0); | ||
}); | ||
|
||
it("should filter out dossiers with internal instructeurs and CPAM instructeurs", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
instructeurs: [ | ||
{ id: "SW5zdHJ1Y3RldXItNjExNTM=", email: "x@example.org" }, | ||
{ id: "xxxxxxx", email: "cpam@example.org" }, | ||
], | ||
}, | ||
]); | ||
expect(await cpamOnly()).toHaveLength(0); | ||
}); | ||
|
||
it("should include dossiers with no internal instructeurs and one CPAM instructeurs", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
instructeurs: [{ id: "xxxxxxx", email: "cpam@example.org" }], | ||
}, | ||
]); | ||
expect(await cpamOnly()).toHaveLength(1); | ||
}); | ||
it("should include dossiers with no internal instructeurs and some CPAM instructeurs", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
instructeurs: [ | ||
{ id: "xxxxxxx", email: "cpam@example.org" }, | ||
{ id: "yyyyyyy", email: "cpam2@example.org" }, | ||
], | ||
}, | ||
]); | ||
expect(await cpamOnly()).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
describe("`notificationSelectionNotChecked()`: dossiers with no notification selection", () => { | ||
it("should filter out dossiers with notification selection checked", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
annotations: [ | ||
{ | ||
id: NOTIFICATION_SELECTION, | ||
label: "Notification Sélection", | ||
stringValue: "oui", | ||
}, | ||
], | ||
}, | ||
]); | ||
expect(await notificationSelectionNotChecked()).toHaveLength(0); | ||
}); | ||
it("should filter out dossiers where dossier elligible is not OUI or NON", async () => { | ||
mockDSCall([ | ||
{ id: "0", annotations: [] }, | ||
{ | ||
id: "1", | ||
annotations: [ | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "peut-être", | ||
}, | ||
], | ||
}, | ||
{ | ||
id: "2", | ||
annotations: [ | ||
{ | ||
id: NOTIFICATION_SELECTION, | ||
label: "Notification Sélection", | ||
stringValue: "", | ||
}, | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "peut-être", | ||
}, | ||
], | ||
}, | ||
]); | ||
expect(await notificationSelectionNotChecked()).toHaveLength(0); | ||
}); | ||
it("should include dossiers with notification selection not checked and dossier elligible OUI or NON", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
annotations: [ | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "OUI", | ||
}, | ||
{ | ||
id: NOTIFICATION_SELECTION, | ||
label: "Notification Sélection", | ||
stringValue: "", | ||
}, | ||
], | ||
}, | ||
{ | ||
id: "2", | ||
annotations: [ | ||
{ | ||
id: NOTIFICATION_SELECTION, | ||
label: "Notification Sélection", | ||
stringValue: "", | ||
}, | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "NON", | ||
}, | ||
], | ||
}, | ||
]); | ||
expect(await notificationSelectionNotChecked()).toHaveLength(2); | ||
}); | ||
}); | ||
|
||
describe("`withoutInstructeurFB()`: dossiers en instruction elligible without FB as an inscructor", () => { | ||
it("should filter out dossiers where dossier elligible is not OUI or NON", async () => { | ||
mockDSCall([ | ||
{ id: "0", annotations: [] }, | ||
{ | ||
id: "1", | ||
annotations: [ | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "peut-être", | ||
}, | ||
], | ||
}, | ||
]); | ||
expect(await withoutInstructeurFB()).toHaveLength(0); | ||
}); | ||
it("should filter out dossiers where dossier elligible is OUI or NON and FB is an instructeur", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
annotations: [ | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "OUI", | ||
}, | ||
], | ||
instructeurs: [{ id: INSTRUCTEUR_FB, email: "x@example.org" }], | ||
}, | ||
{ | ||
id: "2", | ||
annotations: [ | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "NON", | ||
}, | ||
], | ||
instructeurs: [ | ||
{ id: INSTRUCTEUR_FB, email: "x@example.org" }, | ||
{ id: "yyyyyyy", email: "y@example.org" }, | ||
], | ||
}, | ||
]); | ||
expect(await withoutInstructeurFB()).toHaveLength(0); | ||
}); | ||
it("should include dossiers where dossier elligible is OUI or NON and FB is not an instructeur", async () => { | ||
mockDSCall([ | ||
{ | ||
id: "1", | ||
annotations: [ | ||
{ | ||
id: DOSSIER_ELIGIBLE, | ||
label: "Dossier elligible", | ||
stringValue: "OUI", | ||
}, | ||
], | ||
instructeurs: [{ id: "yyyyyyy", email: "y@example.org" }], | ||
}, | ||
]); | ||
expect(await withoutInstructeurFB()).toHaveLength(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.