-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EW-1053 Add and use Test Factories For TSP #5369
Open
MajedAlaitwniCap
wants to merge
19
commits into
main
Choose a base branch
from
EW-1053
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f840ab4
Add and use Test Factories
MajedAlaitwniCap 2676f20
Merge branch 'main' into EW-1053
MajedAlaitwniCap 6184e18
Merge branch 'main' into EW-1053
MajedAlaitwniCap 4e0f4e2
revert ExternalSchoolDto changes
MajedAlaitwniCap 22b41cb
Merge branch 'main' into EW-1053
MajedAlaitwniCap 6e3a643
add and use factories for robj export models
MajedAlaitwniCap 02cb706
Merge branch 'main' into EW-1053
MajedAlaitwniCap e4aa8a3
add robj-export-schueler-migration factory
MajedAlaitwniCap 2fcee4c
add new factories to index
MajedAlaitwniCap 45a4b6a
Merge branch 'main' into EW-1053
MajedAlaitwniCap c71904b
revert adding new factories to index file
MajedAlaitwniCap 87874ac
Merge branch 'main' into EW-1053
MajedAlaitwniCap 662310c
Merge branch 'main' into EW-1053
MajedAlaitwniCap ee42f8e
Merge branch 'main' into EW-1053
MajedAlaitwniCap feda809
Merge branch 'main' of https://github.com/hpi-schul-cloud/schulcloud-…
MajedAlaitwniCap 2d49b6b
modify externalUserDtoFactory
MajedAlaitwniCap 4e6c0f6
reorder test factories to main modules
MajedAlaitwniCap ab87bfc
Merge branch 'main' into EW-1053
mkreuzkam-cap 102ff37
fix nest lint.
mkreuzkam-cap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -13,17 +13,23 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
import { UserDO } from '@shared/domain/domainobject'; | ||
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; | ||
import { userDoFactory } from '@shared/testing'; | ||
import { externalUserDtoFactory } from '@shared/testing/factory/external-user-dto.factory'; | ||
import { oauthDataDtoFactory } from '@shared/testing/factory/oauth-data-dto.factory'; | ||
import { provisioningSystemDtoFactory } from '@shared/testing/factory/provisioning-system-dto.factory'; | ||
import { robjExportLehrerMigrationFactory } from '@shared/testing/factory/robj-export-lehrer-migration.factory'; | ||
import { robjExportSchuelerMigrationFactory } from '@shared/testing/factory/robj-export-schueler-migration.factory'; | ||
import { robjExportSchuleFactory } from '@shared/testing/factory/robj-export-schule.factory'; | ||
import { Logger } from '@src/core/logger'; | ||
import { Account } from '@src/modules/account'; | ||
import { accountDoFactory } from '@src/modules/account/testing'; | ||
import { ExternalUserDto, OauthDataDto, ProvisioningService, ProvisioningSystemDto } from '@src/modules/provisioning'; | ||
import { OauthDataDto, ProvisioningService } from '@src/modules/provisioning'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove @src |
||
import { School } from '@src/modules/school'; | ||
import { schoolFactory } from '@src/modules/school/testing'; | ||
import { System } from '@src/modules/system'; | ||
import { systemFactory } from '@src/modules/system/testing'; | ||
import { SyncStrategyTarget } from '../sync-strategy.types'; | ||
import { TspLegacyMigrationService } from './tsp-legacy-migration.service'; | ||
import { TspFetchService } from './tsp-fetch.service'; | ||
import { TspLegacyMigrationService } from './tsp-legacy-migration.service'; | ||
import { TspOauthDataMapper } from './tsp-oauth-data.mapper'; | ||
import { TspSyncConfig } from './tsp-sync.config'; | ||
import { TspSyncService } from './tsp-sync.service'; | ||
|
@@ -164,12 +170,12 @@ describe(TspSyncStrategy.name, () => { | |
describe('sync', () => { | ||
describe('when sync is called', () => { | ||
const setup = () => { | ||
const oauthDataDto = new OauthDataDto({ | ||
system: new ProvisioningSystemDto({ | ||
const oauthDataDto = oauthDataDtoFactory.build({ | ||
system: provisioningSystemDtoFactory.build({ | ||
systemId: faker.string.alpha(), | ||
provisioningStrategy: SystemProvisioningStrategy.TSP, | ||
}), | ||
externalUser: new ExternalUserDto({ | ||
externalUser: externalUserDtoFactory.build({ | ||
externalId: faker.string.alpha(), | ||
}), | ||
}); | ||
|
@@ -301,10 +307,7 @@ describe(TspSyncStrategy.name, () => { | |
|
||
describe('when school does not exist', () => { | ||
const setup = () => { | ||
const tspSchool: RobjExportSchule = { | ||
schuleNummer: faker.string.alpha(), | ||
schuleName: faker.string.alpha(), | ||
}; | ||
const tspSchool = robjExportSchuleFactory.build(); | ||
const tspSchools = [tspSchool]; | ||
|
||
setupMockServices({ | ||
|
@@ -323,10 +326,7 @@ describe(TspSyncStrategy.name, () => { | |
|
||
describe('when school does exist', () => { | ||
const setup = () => { | ||
const tspSchool: RobjExportSchule = { | ||
schuleNummer: faker.string.alpha(), | ||
schuleName: faker.string.alpha(), | ||
}; | ||
const tspSchool = robjExportSchuleFactory.build(); | ||
const tspSchools = [tspSchool]; | ||
const school = schoolFactory.build(); | ||
|
||
|
@@ -347,10 +347,8 @@ describe(TspSyncStrategy.name, () => { | |
|
||
describe('when tsp school does not have a schulnummer', () => { | ||
const setup = () => { | ||
const tspSchool: RobjExportSchule = { | ||
schuleNummer: undefined, | ||
schuleName: faker.string.alpha(), | ||
}; | ||
const tspSchool = robjExportSchuleFactory.build(); | ||
tspSchool.schuleNummer = undefined; | ||
const tspSchools = [tspSchool]; | ||
|
||
setupMockServices({ | ||
|
@@ -371,14 +369,14 @@ describe(TspSyncStrategy.name, () => { | |
|
||
describe('when UidAlt or UidNeu is missing during migration', () => { | ||
const setup = () => { | ||
const tspTeacher: RobjExportLehrerMigration = { | ||
const tspTeacher = robjExportLehrerMigrationFactory.build({ | ||
lehrerUidAlt: undefined, | ||
lehrerUidNeu: faker.string.alpha(), | ||
}; | ||
const tspStudent: RobjExportSchuelerMigration = { | ||
}); | ||
const tspStudent = robjExportSchuelerMigrationFactory.build({ | ||
schuelerUidAlt: faker.string.alpha(), | ||
schuelerUidNeu: undefined, | ||
}; | ||
}); | ||
|
||
setupMockServices({ | ||
fetchedStudentMigrations: [tspStudent], | ||
|
@@ -397,10 +395,10 @@ describe(TspSyncStrategy.name, () => { | |
|
||
describe('when no user is found during migration', () => { | ||
const setup = () => { | ||
const tspTeacher: RobjExportLehrerMigration = { | ||
const tspTeacher = robjExportLehrerMigrationFactory.build({ | ||
lehrerUidAlt: faker.string.alpha(), | ||
lehrerUidNeu: faker.string.alpha(), | ||
}; | ||
}); | ||
|
||
setupMockServices({ | ||
fetchedTeacherMigrations: [tspTeacher], | ||
|
@@ -421,10 +419,10 @@ describe(TspSyncStrategy.name, () => { | |
|
||
describe('when no account is found during migration', () => { | ||
const setup = () => { | ||
const tspTeacher: RobjExportLehrerMigration = { | ||
const tspTeacher = robjExportLehrerMigrationFactory.build({ | ||
lehrerUidAlt: faker.string.alpha(), | ||
lehrerUidNeu: faker.string.alpha(), | ||
}; | ||
}); | ||
|
||
setupMockServices({ | ||
fetchedTeacherMigrations: [tspTeacher], | ||
|
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { createMock, DeepMocked } from '@golevelup/ts-jest'; | ||
import { System, SystemService } from '@modules/system'; | ||
import { systemFactory } from '@modules/system/testing'; | ||
import { InternalServerErrorException } from '@nestjs/common'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; | ||
import { oauthDataDtoFactory } from '@shared/testing/factory/oauth-data-dto.factory'; | ||
import { provisioningDtoFactory } from '@shared/testing/factory/provisioning-dto.factory'; | ||
import { provisioningSystemDtoFactory } from '@shared/testing/factory/provisioning-system-dto.factory'; | ||
import { systemFactory } from '@src/modules/system/testing'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove @src |
||
import { | ||
ExternalUserDto, | ||
OauthDataDto, | ||
|
@@ -12,8 +15,8 @@ import { | |
ProvisioningSystemDto, | ||
} from '../dto'; | ||
import { IservProvisioningStrategy, OidcMockProvisioningStrategy, SanisProvisioningStrategy } from '../strategy'; | ||
import { ProvisioningService } from './provisioning.service'; | ||
import { TspProvisioningStrategy } from '../strategy/tsp/tsp.strategy'; | ||
import { ProvisioningService } from './provisioning.service'; | ||
|
||
describe('ProvisioningService', () => { | ||
let module: TestingModule; | ||
|
@@ -83,18 +86,18 @@ describe('ProvisioningService', () => { | |
provisioningUrl: 'https://api.moin.schule/', | ||
provisioningStrategy: SystemProvisioningStrategy.SANIS, | ||
}); | ||
const provisioningSystemDto: ProvisioningSystemDto = new ProvisioningSystemDto({ | ||
const provisioningSystemDto: ProvisioningSystemDto = provisioningSystemDtoFactory.build({ | ||
systemId: system.id, | ||
provisioningUrl: 'https://api.moin.schule/', | ||
provisioningStrategy: SystemProvisioningStrategy.SANIS, | ||
}); | ||
const oauthDataDto: OauthDataDto = new OauthDataDto({ | ||
const oauthDataDto: OauthDataDto = oauthDataDtoFactory.build({ | ||
system: provisioningSystemDto, | ||
externalUser: new ExternalUserDto({ | ||
externalId: 'externalUserId', | ||
}), | ||
}); | ||
const provisioningDto: ProvisioningDto = new ProvisioningDto({ | ||
const provisioningDto: ProvisioningDto = provisioningDtoFactory.build({ | ||
externalUserId: 'externalUserId', | ||
}); | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid '@src'