-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(app): refactor mocks and fixtures
- Loading branch information
Showing
11 changed files
with
235 additions
and
151 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
47 changes: 47 additions & 0 deletions
47
app/integration_test/fixtures/drugs/with_any_fallback_guideline.dart
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,47 @@ | ||
import 'package:app/common/models/drug/drug.dart'; | ||
import 'package:app/common/models/drug/guideline.dart'; | ||
import 'package:app/common/models/drug/warning_level.dart'; | ||
|
||
final drugWithAnyFallbackGuideline = Drug( | ||
id: '658df37b3aa92cbd80bbe352', | ||
version: 1, | ||
name: 'warfarin', | ||
rxNorm: 'RxNorm:11289', | ||
annotations: DrugAnnotations( | ||
drugclass: 'Blood thinner', | ||
indication: 'Warfarin is used to prevent and treat blood clots.', | ||
brandNames: ['Coumadin', 'Jantoven'], | ||
), | ||
guidelines: [ | ||
Guideline( | ||
id: '66b50b2433cbe5c07ee3101d', | ||
version: 4, | ||
lookupkey: { | ||
'CYP2C9': ['*'], | ||
'VKORC1': ['*'], | ||
'CYP4F2': ['*'], | ||
'CYP2C': ['*'], | ||
}, | ||
externalData: [ | ||
GuidelineExtData( | ||
source: 'CPIC', | ||
guidelineName: 'CPIC® Guideline for Pharmacogenetics-Guided Warfarin Dosing', | ||
guidelineUrl: 'https://cpicpgx.org/guidelines/guideline-for-warfarin-and-cyp2c9-and-vkorc1/', | ||
implications: { | ||
'CYP2C9': 'No implication', | ||
'VKORC1': 'No implication', | ||
'CYP4F2': 'No implication', | ||
'CYP2C': 'No implication', | ||
}, | ||
recommendation: 'No recommendation', | ||
comments: null, | ||
), | ||
], | ||
annotations: GuidelineAnnotations( | ||
implication: 'More information is needed to calculate your warfarin dose.', | ||
recommendation: 'Consult your pharmacist or doctor for more information.', | ||
warningLevel: WarningLevel.yellow, | ||
), | ||
), | ||
], | ||
); |
44 changes: 44 additions & 0 deletions
44
app/integration_test/fixtures/drugs/with_proper_guideline.dart
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,44 @@ | ||
import 'package:app/common/models/drug/drug.dart'; | ||
import 'package:app/common/models/drug/guideline.dart'; | ||
import 'package:app/common/models/drug/warning_level.dart'; | ||
|
||
final drugWithProperGuideline = Drug( | ||
id: '6407768b92a4868065b6c466', | ||
version: 1, | ||
name: 'ibuprofen', | ||
rxNorm: 'RxNorm:5640', | ||
annotations: DrugAnnotations( | ||
drugclass: 'Non-steroidal anti-inflammatory drug (NSAID)', | ||
indication: 'Ibuprofen is used to treat pain, fever, and inflammation.', | ||
brandNames: [ | ||
'Advil', | ||
'Ibutab', | ||
'Motrin', | ||
'Neoprofen', | ||
'Proprinal', | ||
'Vicoprofen', | ||
]), | ||
guidelines: [ | ||
Guideline( | ||
id: '64552859a1b68082babc8c31', | ||
version: 1, | ||
lookupkey: { | ||
'CYP2C9': ['2.0'] | ||
}, | ||
externalData: [ | ||
GuidelineExtData( | ||
source: 'CPIC', | ||
guidelineName: 'CYP2C9 and NSAIDs', | ||
guidelineUrl: 'https://cpicpgx.org/guidelines/cpic-guideline-for-nsaids-based-on-cyp2c9-genotype/', | ||
implications: {'CYP2C9': 'Normal metabolism'}, | ||
recommendation: 'Initiate therapy with recommended starting dose. In accordance with the prescribing information, use the lowest effective dosage for shortest duration consistent with individual patient treatment goals.', | ||
comments: 'n/a') | ||
], | ||
annotations: GuidelineAnnotations( | ||
implication: 'You break down ibuprofen as expected.', | ||
recommendation: 'You can use ibuprofen at standard dose. Consult your pharmacist or doctor for more information.', | ||
warningLevel: WarningLevel.green, | ||
), | ||
), | ||
], | ||
); |
13 changes: 13 additions & 0 deletions
13
app/integration_test/fixtures/drugs/without_guidelines.dart
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,13 @@ | ||
import 'package:app/common/models/drug/drug.dart'; | ||
|
||
final drugWithoutGuidelines = Drug( | ||
id: '64c187431006f51bc6e24959', | ||
version: 2, | ||
name: 'mirabegron', | ||
rxNorm: 'RxNorm:1300786', | ||
annotations: DrugAnnotations( | ||
drugclass: 'Urology drug', | ||
indication: 'Mirabegron is used to treat overactive bladder.', | ||
brandNames: ['Myrbetriq']), | ||
guidelines: [], | ||
); |
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,41 @@ | ||
import 'package:app/common/models/drug/drug.dart'; | ||
import 'package:app/common/models/userdata/genotype_result.dart'; | ||
import 'package:app/common/models/userdata/lab_result.dart'; | ||
import 'package:app/common/models/userdata/userdata.dart'; | ||
|
||
class _UserDataConfig { | ||
_UserDataConfig({ | ||
required this.gene, | ||
required this.lookupkey, | ||
}); | ||
final String gene; | ||
final String lookupkey; | ||
final String phenotype = 'phenotype does not matter for test'; | ||
final String variant = 'variant does not matter for test'; | ||
final String allelesTested = 'allelesTested does not matter for test'; | ||
} | ||
|
||
void setUserDataForDrug(Drug drug) { | ||
UserData.instance.labData = UserData.instance.labData ?? []; | ||
UserData.instance.genotypeResults = UserData.instance.genotypeResults ?? {}; | ||
final userDataConfig = _UserDataConfig( | ||
gene: drug.guidelines.first.lookupkey.keys.first, | ||
lookupkey: | ||
drug.guidelines.first.lookupkey.values.first.first, | ||
); | ||
UserData.instance.labData!.add( | ||
LabResult( | ||
gene: userDataConfig.gene, | ||
variant: userDataConfig.variant, | ||
phenotype: userDataConfig.phenotype, | ||
allelesTested: userDataConfig.allelesTested, | ||
), | ||
); | ||
UserData.instance.genotypeResults![userDataConfig.gene] = GenotypeResult( | ||
gene: userDataConfig.gene, | ||
phenotype: userDataConfig.phenotype, | ||
variant: userDataConfig.variant, | ||
allelesTested: userDataConfig.variant, | ||
lookupkey: userDataConfig.lookupkey, | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import 'package:app/drug/cubit.dart'; | ||
import 'package:bloc_test/bloc_test.dart'; | ||
|
||
class MockDrugsCubit extends MockCubit<DrugState> implements DrugCubit {} |
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,7 @@ | ||
import 'package:app/common/widgets/drug_list/cubit.dart'; | ||
import 'package:bloc_test/bloc_test.dart'; | ||
|
||
class MockDrugListCubit extends MockCubit<DrugListState> implements DrugListCubit { | ||
@override | ||
FilterState get filter => FilterState.initial(); | ||
} |
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,4 @@ | ||
import 'package:app/login/cubit.dart'; | ||
import 'package:bloc_test/bloc_test.dart'; | ||
|
||
class MockLoginCubit extends MockCubit<LoginState> implements LoginCubit {} |
Oops, something went wrong.