Tests for Task 3: Simulate one day¶
This page describes the tests for Task 3. For each task, we provide a short description of the test, information about how to recreate the test in ipython3
, and the expected result.
To run the tasks for Task 3, run the following command at the Linux command-line:
$ py.test -xvk 'one'
When you run this command, you’ll see that some tests are labelled as SKIPPED
. You can ignore these tests for now,we’ll come back to them later when we introduce vaccines into our simulation.
Test 0¶
Description: Check that the days contagious for infected people who are not ready to recover are incremented properly.
To run this test in ipython3
:
city = [('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 100)] # loc: 2
sir.simulate_one_day(city, 200)
Expected result:
[('I', 1), # loc: 0
('I', 2), # loc: 1
('I', 101)] # loc: 2
Test 1¶
Description: Check that infected people are converted to the recovered state properly.
To run this test in ipython3
:
city = [('I', 2), # loc: 0
('I', 2), # loc: 1
('I', 2)] # loc: 2
sir.simulate_one_day(city, 3)
Expected result:
[('R', 0), # loc: 0
('R', 0), # loc: 1
('R', 0)] # loc: 2
Test 2¶
Description: Check that the days contagious for recovered people are incremented properly.
To run this test in ipython3
:
city = [('R', 0), # loc: 0
('R', 10), # loc: 1
('R', 100)] # loc: 2
sir.simulate_one_day(city, 3)
Expected result:
[('R', 1), # loc: 0
('R', 11), # loc: 1
('R', 101)] # loc: 2
Test 3¶
Description: Purpose: Check that a susceptible person with infected neighbors becomes infected.
To run this test in ipython3
:
city = [('I', 1), # loc: 0
('S', 0), # loc: 1
('I', 1)] # loc: 2
sir.simulate_one_day(city, 3)
Expected result:
[('I', 2), # loc: 0
('I', 0), # loc: 1
('I', 2)] # loc: 2
Test 4¶
Description: Check that a susceptible person becomes infected, even as its neighbors recover in the same day.
To run this test in ipython3
:
city = [('I', 1), # loc: 0
('S', 0), # loc: 1
('I', 1)] # loc: 2
sir.simulate_one_day(city, 2)
Expected result:
[('R', 0), # loc: 0
('I', 0), # loc: 1
('R', 0)] # loc: 2
Test 5¶
Description: Check that two susceptible people become infected.
To run this test in ipython3
:
city = [('S', 0), # loc: 0
('I', 0), # loc: 1
('S', 0)] # loc: 2
sir.simulate_one_day(city, 2)
Expected result:
[('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 0)] # loc: 2
Test 6¶
Description: Check susceptible people with no infected neighbors.
To run this test in ipython3
:
city = [('S', 0), # loc: 0
('S', 0), # loc: 1
('S', 0)] # loc: 2
sir.simulate_one_day(city, 2)
Expected result:
[('S', 1), # loc: 0
('S', 1), # loc: 1
('S', 1)] # loc: 2
Test 7¶
Description: Check a large city with medium infection rate
To run this test in ipython3
:
city = [('I', 1), # loc: 0
('R', 0), # loc: 1
('S', 0), # loc: 2
('S', 0), # loc: 3
('S', 0), # loc: 4
('R', 0), # loc: 5
('S', 0), # loc: 6
('S', 0), # loc: 7
('S', 0), # loc: 8
('I', 1), # loc: 9
('I', 1), # loc: 10
('R', 0), # loc: 11
('S', 0), # loc: 12
('S', 0), # loc: 13
('S', 0), # loc: 14
('R', 0), # loc: 15
('S', 0), # loc: 16
('S', 0), # loc: 17
('S', 0), # loc: 18
('I', 1), # loc: 19
('S', 0), # loc: 20
('S', 0), # loc: 21
('S', 0), # loc: 22
('I', 1), # loc: 23
('R', 0), # loc: 24
('S', 0), # loc: 25
('S', 0), # loc: 26
('S', 0), # loc: 27
('R', 0), # loc: 28
('S', 0), # loc: 29
('S', 0), # loc: 30
('S', 0), # loc: 31
('I', 1), # loc: 32
('I', 1), # loc: 33
('R', 0), # loc: 34
('S', 0), # loc: 35
('S', 0), # loc: 36
('S', 0), # loc: 37
('R', 0), # loc: 38
('S', 0), # loc: 39
('S', 0), # loc: 40
('S', 0), # loc: 41
('I', 1), # loc: 42
('S', 0), # loc: 43
('S', 0), # loc: 44
('S', 0), # loc: 45
('S', 0), # loc: 46
('S', 0), # loc: 47
('S', 0)] # loc: 48
sir.simulate_one_day(city, 2)
Expected result:
[('R', 0), # loc: 0
('R', 1), # loc: 1
('S', 1), # loc: 2
('S', 1), # loc: 3
('S', 1), # loc: 4
('R', 1), # loc: 5
('S', 1), # loc: 6
('S', 1), # loc: 7
('I', 0), # loc: 8
('R', 0), # loc: 9
('R', 0), # loc: 10
('R', 1), # loc: 11
('S', 1), # loc: 12
('S', 1), # loc: 13
('S', 1), # loc: 14
('R', 1), # loc: 15
('S', 1), # loc: 16
('S', 1), # loc: 17
('I', 0), # loc: 18
('R', 0), # loc: 19
('I', 0), # loc: 20
('S', 1), # loc: 21
('I', 0), # loc: 22
('R', 0), # loc: 23
('R', 1), # loc: 24
('S', 1), # loc: 25
('S', 1), # loc: 26
('S', 1), # loc: 27
('R', 1), # loc: 28
('S', 1), # loc: 29
('S', 1), # loc: 30
('I', 0), # loc: 31
('R', 0), # loc: 32
('R', 0), # loc: 33
('R', 1), # loc: 34
('S', 1), # loc: 35
('S', 1), # loc: 36
('S', 1), # loc: 37
('R', 1), # loc: 38
('S', 1), # loc: 39
('S', 1), # loc: 40
('I', 0), # loc: 41
('R', 0), # loc: 42
('I', 0), # loc: 43
('S', 1), # loc: 44
('S', 1), # loc: 45
('S', 1), # loc: 46
('S', 1), # loc: 47
('I', 0)] # loc: 48
Test 8¶
Description: Check a large city with medium infection rate. Last person in the city gets infected.
To run this test in ipython3
:
city = [('S', 1), # loc: 0
('R', 0), # loc: 1
('S', 0), # loc: 2
('S', 0), # loc: 3
('S', 0), # loc: 4
('R', 0), # loc: 5
('S', 0), # loc: 6
('S', 0), # loc: 7
('S', 0), # loc: 8
('I', 1), # loc: 9
('I', 1), # loc: 10
('R', 0), # loc: 11
('S', 0), # loc: 12
('S', 0), # loc: 13
('S', 0), # loc: 14
('R', 0), # loc: 15
('S', 0), # loc: 16
('S', 0), # loc: 17
('S', 0), # loc: 18
('I', 1), # loc: 19
('S', 0), # loc: 20
('S', 0), # loc: 21
('S', 0), # loc: 22
('I', 1), # loc: 23
('R', 0), # loc: 24
('S', 0), # loc: 25
('S', 0), # loc: 26
('S', 0), # loc: 27
('R', 0), # loc: 28
('S', 0), # loc: 29
('S', 0), # loc: 30
('S', 0), # loc: 31
('I', 1), # loc: 32
('I', 1), # loc: 33
('R', 0), # loc: 34
('S', 0), # loc: 35
('S', 0), # loc: 36
('S', 0), # loc: 37
('R', 0), # loc: 38
('S', 0), # loc: 39
('S', 0), # loc: 40
('S', 0), # loc: 41
('I', 1), # loc: 42
('S', 0), # loc: 43
('S', 0), # loc: 44
('S', 0), # loc: 45
('R', 0), # loc: 46
('I', 0), # loc: 47
('S', 0)] # loc: 48
sir.simulate_one_day(city, 2)
Expected result:
[('S', 2), # loc: 0
('R', 1), # loc: 1
('S', 1), # loc: 2
('S', 1), # loc: 3
('S', 1), # loc: 4
('R', 1), # loc: 5
('S', 1), # loc: 6
('S', 1), # loc: 7
('I', 0), # loc: 8
('R', 0), # loc: 9
('R', 0), # loc: 10
('R', 1), # loc: 11
('S', 1), # loc: 12
('S', 1), # loc: 13
('S', 1), # loc: 14
('R', 1), # loc: 15
('S', 1), # loc: 16
('S', 1), # loc: 17
('I', 0), # loc: 18
('R', 0), # loc: 19
('I', 0), # loc: 20
('S', 1), # loc: 21
('I', 0), # loc: 22
('R', 0), # loc: 23
('R', 1), # loc: 24
('S', 1), # loc: 25
('S', 1), # loc: 26
('S', 1), # loc: 27
('R', 1), # loc: 28
('S', 1), # loc: 29
('S', 1), # loc: 30
('I', 0), # loc: 31
('R', 0), # loc: 32
('R', 0), # loc: 33
('R', 1), # loc: 34
('S', 1), # loc: 35
('S', 1), # loc: 36
('S', 1), # loc: 37
('R', 1), # loc: 38
('S', 1), # loc: 39
('S', 1), # loc: 40
('I', 0), # loc: 41
('R', 0), # loc: 42
('I', 0), # loc: 43
('S', 1), # loc: 44
('S', 1), # loc: 45
('R', 1), # loc: 46
('I', 1), # loc: 47
('I', 0)] # loc: 48
Tests for Task 6-3: add vaxxed people¶
This section describes tests for Task 3 that include vaccinated people. Work through these tests after you have completed Tasks 1-5.
To run the tasks for Task 6-3, run the following command at the Linux command-line:
$ py.test -xvk one --runvax
Test 0¶
Description: Check that the days in state gets incremented properly for vaxxed people.
To run this test in ipython3
:
city = [('V', 0), # loc: 0
('V', 1), # loc: 1
('V', 100)] # loc: 2
sir.simulate_one_day(city, 200)
Expected result:
[('V', 1), # loc: 0
('V', 2), # loc: 1
('V', 101)] # loc: 2
Test 1¶
Description: Purpose: Check that susceptible person with an infected neighbor becomes infected, but that the vaxxed person (with the same infected neighbor) does not.
To run this test in ipython3
:
city = [('S', 0), # loc: 0
('I', 0), # loc: 1
('V', 0)] # loc: 2
sir.simulate_one_day(city, 2)
Expected result:
[('I', 0), # loc: 0
('I', 1), # loc: 1
('V', 1)] # loc: 2
Test 2¶
Description: Large city with medium infection rate. All the susceptible people are protected by vaxxed and recovered neighbors.
To run this test in ipython3
:
city = [('I', 1), # loc: 0
('R', 0), # loc: 1
('S', 0), # loc: 2
('S', 0), # loc: 3
('S', 0), # loc: 4
('R', 0), # loc: 5
('S', 0), # loc: 6
('S', 0), # loc: 7
('V', 0), # loc: 8
('I', 1), # loc: 9
('I', 1), # loc: 10
('R', 0), # loc: 11
('S', 0), # loc: 12
('S', 0), # loc: 13
('S', 0), # loc: 14
('R', 0), # loc: 15
('S', 0), # loc: 16
('S', 0), # loc: 17
('V', 0), # loc: 18
('I', 1), # loc: 19
('V', 0), # loc: 20
('S', 0), # loc: 21
('V', 0), # loc: 22
('I', 1), # loc: 23
('R', 0), # loc: 24
('S', 0), # loc: 25
('S', 0), # loc: 26
('S', 0), # loc: 27
('R', 0), # loc: 28
('S', 0), # loc: 29
('S', 0), # loc: 30
('V', 0), # loc: 31
('I', 1), # loc: 32
('I', 1), # loc: 33
('R', 0), # loc: 34
('S', 0), # loc: 35
('S', 0), # loc: 36
('S', 0), # loc: 37
('R', 0), # loc: 38
('S', 0), # loc: 39
('S', 0), # loc: 40
('V', 0), # loc: 41
('I', 1), # loc: 42
('V', 0), # loc: 43
('S', 0), # loc: 44
('S', 0), # loc: 45
('S', 0), # loc: 46
('S', 0), # loc: 47
('V', 0)] # loc: 48
sir.simulate_one_day(city, 2)
Expected result:
[('R', 0), # loc: 0
('R', 1), # loc: 1
('S', 1), # loc: 2
('S', 1), # loc: 3
('S', 1), # loc: 4
('R', 1), # loc: 5
('S', 1), # loc: 6
('S', 1), # loc: 7
('V', 1), # loc: 8
('R', 0), # loc: 9
('R', 0), # loc: 10
('R', 1), # loc: 11
('S', 1), # loc: 12
('S', 1), # loc: 13
('S', 1), # loc: 14
('R', 1), # loc: 15
('S', 1), # loc: 16
('S', 1), # loc: 17
('V', 1), # loc: 18
('R', 0), # loc: 19
('V', 1), # loc: 20
('S', 1), # loc: 21
('V', 1), # loc: 22
('R', 0), # loc: 23
('R', 1), # loc: 24
('S', 1), # loc: 25
('S', 1), # loc: 26
('S', 1), # loc: 27
('R', 1), # loc: 28
('S', 1), # loc: 29
('S', 1), # loc: 30
('V', 1), # loc: 31
('R', 0), # loc: 32
('R', 0), # loc: 33
('R', 1), # loc: 34
('S', 1), # loc: 35
('S', 1), # loc: 36
('S', 1), # loc: 37
('R', 1), # loc: 38
('S', 1), # loc: 39
('S', 1), # loc: 40
('V', 1), # loc: 41
('R', 0), # loc: 42
('V', 1), # loc: 43
('S', 1), # loc: 44
('S', 1), # loc: 45
('S', 1), # loc: 46
('S', 1), # loc: 47
('V', 1)] # loc: 48