-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): Add helper functions for creating test data in referentie…
…l modules - Created AcademieHelper with createAcademie function - Added DepartementHelper with createDepartement function - Implemented RegionAcademiqueHelper with createRegionAcademique function - Standardized test data creation for referentiel entities
- Loading branch information
Philippe de MANGOU
committed
Jan 31, 2025
1 parent
0137daa
commit 1e019be
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
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,18 @@ | ||
import mongoose from "mongoose"; | ||
import { AcademieGateway } from "@admin/core/referentiel/academie/Academie.gateway"; | ||
import { AcademieModel } from "@admin/core/referentiel/academie/Academie.model"; | ||
import { getAdminTestModuleRef } from "../../setUpAdminTest"; | ||
|
||
export const createAcademie = async (academie?: Partial<AcademieModel>) => { | ||
const adminTestModule = getAdminTestModuleRef(); | ||
const academieGateway = adminTestModule.get<AcademieGateway>(AcademieGateway); | ||
return await academieGateway.create({ | ||
id: new mongoose.Types.ObjectId().toString(), | ||
code: "001", | ||
libelle: "LYON", | ||
regionAcademique: "AUVERGNE-RHONE-ALPES", | ||
dateCreationSI: new Date("2024-07-31"), | ||
dateDerniereModificationSI: new Date("2024-07-31"), | ||
...academie, | ||
}); | ||
}; |
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,19 @@ | ||
import mongoose from "mongoose"; | ||
import { DepartementGateway } from "@admin/core/referentiel/departement/Departement.gateway"; | ||
import { DepartementModel } from "@admin/core/referentiel/departement/Departement.model"; | ||
import { getAdminTestModuleRef } from "../../setUpAdminTest"; | ||
|
||
export const createDepartement = async (departement?: Partial<DepartementModel>) => { | ||
const adminTestModule = getAdminTestModuleRef(); | ||
const departementGateway = adminTestModule.get<DepartementGateway>(DepartementGateway); | ||
return await departementGateway.create({ | ||
id: new mongoose.Types.ObjectId().toString(), | ||
code: "01", | ||
libelle: "AIN", | ||
academie: "LYON", | ||
regionAcademique: "AUVERGNE-RHONE-ALPES", | ||
dateCreationSI: new Date("2024-07-31"), | ||
dateDerniereModificationSI: new Date("2024-07-31"), | ||
...departement, | ||
}); | ||
}; |
17 changes: 17 additions & 0 deletions
17
apiv2/test/admin/referentiel/helpers/RegionAcademiqueHelper.ts
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,17 @@ | ||
import mongoose from "mongoose"; | ||
import { RegionAcademiqueGateway } from "@admin/core/referentiel/regionAcademique/RegionAcademique.gateway"; | ||
import { RegionAcademiqueModel } from "@admin/core/referentiel/regionAcademique/RegionAcademique.model"; | ||
import { getAdminTestModuleRef } from "../../setUpAdminTest"; | ||
|
||
export const createRegionAcademique = async (regionAcademique?: Partial<RegionAcademiqueModel>) => { | ||
const adminTestModule = getAdminTestModuleRef(); | ||
const regionAcademiqueGateway = adminTestModule.get<RegionAcademiqueGateway>(RegionAcademiqueGateway); | ||
return await regionAcademiqueGateway.create({ | ||
id: new mongoose.Types.ObjectId().toString(), | ||
code: "BRE", | ||
libelle: "BRETAGNE", | ||
zone: "B", | ||
dateDerniereModificationSI: new Date("2024-07-31"), | ||
...regionAcademique, | ||
}); | ||
}; |