Skip to content
This repository was archived by the owner on Nov 24, 2021. It is now read-only.

Commit cf4e19b

Browse files
committed
CovidSim connector: Add integration tests for regional parameter files
These are tightly tied to the model's data directory paths, and the connector writes to the input file directory. Hence these are added as integration rather than unit tests.
1 parent 8469567 commit cf4e19b

File tree

1 file changed

+90
-1
lines changed

1 file changed

+90
-1
lines changed

packages/mrc-ide-covidsim/test/integration/imperial-integration-test.ts

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,100 @@
1-
import * as temp from 'temp'
21
import * as fs from 'fs'
2+
import * as path from 'path'
3+
import * as temp from 'temp'
34
import { assert } from 'chai'
45
import { ImperialModel } from '../../src/imperial'
56
import { BIN_DIR, MODEL_DATA_DIR } from '../../src/config'
67
import { input } from '@covid-modeling/api'
78

89
suite('imperial integration', () => {
10+
const testRegions = [
11+
{
12+
region: 'CA',
13+
subregion: undefined,
14+
expectedAdminPath: 'Canada_admin.txt',
15+
expectedPopulationDensityPath: 'wpop_usacan.txt',
16+
expectedPreParameterPath: 'preUK_R0=2.0.txt',
17+
},
18+
{
19+
region: 'NG',
20+
subregion: undefined,
21+
expectedAdminPath: 'Nigeria_admin.txt',
22+
expectedPopulationDensityPath: 'wpop_eur.txt',
23+
expectedPreParameterPath: 'preNG_R0=2.0.txt',
24+
},
25+
{
26+
region: 'RU',
27+
subregion: undefined,
28+
expectedAdminPath: 'Russia_admin.txt',
29+
expectedPopulationDensityPath: 'wpop_eur.txt',
30+
expectedPreParameterPath: 'preUK_R0=2.0.txt',
31+
},
32+
{
33+
region: 'GB',
34+
subregion: undefined,
35+
expectedAdminPath: 'United_Kingdom_admin.txt',
36+
expectedPopulationDensityPath: 'wpop_eur.txt',
37+
expectedPreParameterPath: 'preUK_R0=2.0.txt',
38+
},
39+
{
40+
region: 'US',
41+
subregion: undefined,
42+
expectedAdminPath: 'United_States_admin.txt',
43+
expectedPopulationDensityPath: 'wpop_usacan.txt',
44+
expectedPreParameterPath: 'preUS_R0=2.0.txt',
45+
},
46+
{
47+
region: 'US',
48+
subregion: 'US-NY',
49+
expectedAdminPath: 'admin-params.txt',
50+
expectedPopulationDensityPath: 'wpop_usacan.txt',
51+
expectedPreParameterPath: 'preUS_R0=2.0.txt',
52+
},
53+
]
54+
testRegions.forEach(testRegion => {
55+
test(`finds parameter files for region ${testRegion.region} and subregion ${testRegion.subregion}`, () => {
56+
const modelInput: input.ModelInput = {
57+
region: testRegion.region,
58+
subregion: testRegion.subregion,
59+
parameters: {
60+
calibrationDate: '2020-03-20',
61+
calibrationCaseCount: 500,
62+
calibrationDeathCount: 120,
63+
r0: null,
64+
interventionPeriods: [],
65+
},
66+
}
67+
68+
const logDir = temp.mkdirSync()
69+
const inputDir = temp.mkdirSync()
70+
const outputDir = temp.mkdirSync()
71+
const binDir = temp.mkdirSync()
72+
73+
const model = new ImperialModel(
74+
1,
75+
binDir,
76+
logDir,
77+
MODEL_DATA_DIR,
78+
inputDir,
79+
outputDir
80+
)
81+
82+
const runnerModelInput = model.inputs(modelInput)
83+
assert.equal(
84+
runnerModelInput.adminFilePath,
85+
path.join(inputDir, testRegion.expectedAdminPath)
86+
)
87+
assert.equal(
88+
runnerModelInput.populationDensityFilePath,
89+
path.join(
90+
MODEL_DATA_DIR,
91+
'populations',
92+
testRegion.expectedPopulationDensityPath
93+
)
94+
)
95+
})
96+
})
97+
998
test('run imperial model for Wyoming', async () => {
1099
const logDir = temp.mkdirSync()
11100
const inputDir = temp.mkdirSync()

0 commit comments

Comments
 (0)