Tests for Task 8: Vaccinate city¶
This page describes the tests for Task 8. 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 8, run the following command at the Linux command-line:
$ py.test -xvk 'vaccinate_city'
Test 0¶
Description: No one wants to be vaccinated except the infected person. No one gets vaxxed
To run this test in ipython3
:
city = [('S', 0, 0.0), # loc: 0
('S', 10, 0.0), # loc: 1
('S', 0, 0.0), # loc: 2
('S', 0, 0.0), # loc: 3
('S', 0, 0.0), # loc: 4
('I', 0, 1.0), # loc: 5
('S', 0, 0.0)] # loc: 6
sir.vaccinate_city(city, 20170217)
Expected result:
[('S', 0), # loc: 0
('S', 10), # loc: 1
('S', 0), # loc: 2
('S', 0), # loc: 3
('S', 0), # loc: 4
('I', 0), # loc: 5
('S', 0)] # loc: 6
Test 1¶
Description: Everyone is falling over themselves to get vaccinated. The susceptible people all get vaccinated.
To run this test in ipython3
:
city = [('S', 0, 1.0), # loc: 0
('S', 0, 1.0), # loc: 1
('S', 0, 1.0), # loc: 2
('S', 0, 1.0), # loc: 3
('S', 0, 1.0), # loc: 4
('I', 5, 1.0), # loc: 5
('S', 0, 1.0)] # loc: 6
sir.vaccinate_city(city, 20170217)
Expected result:
[('V', 0), # loc: 0
('V', 0), # loc: 1
('V', 0), # loc: 2
('V', 0), # loc: 3
('V', 0), # loc: 4
('I', 5), # loc: 5
('V', 0)] # loc: 6
Test 2¶
Description: Everyone wants to get vaccinated, but no one is eligible.
To run this test in ipython3
:
city = [('I', 0, 1.0), # loc: 0
('I', 1, 1.0), # loc: 1
('I', 2, 1.0), # loc: 2
('R', 0, 1.0)] # loc: 3
sir.vaccinate_city(city, 20170217)
Expected result:
[('I', 0), # loc: 0
('I', 1), # loc: 1
('I', 2), # loc: 2
('R', 0)] # loc: 3
Test 3¶
Description: High level of interest. All but one susceptible person ends up vaccinated.
To run this test in ipython3
:
city = [('S', 0, 0.8), # loc: 0
('S', 0, 0.8), # loc: 1
('S', 0, 0.8), # loc: 2
('S', 0, 0.8), # loc: 3
('S', 0, 0.8), # loc: 4
('I', 0, 1.0), # loc: 5
('S', 0, 0.8)] # loc: 6
sir.vaccinate_city(city, 20170217)
Expected result:
[('V', 0), # loc: 0
('V', 0), # loc: 1
('V', 0), # loc: 2
('V', 0), # loc: 3
('S', 0), # loc: 4
('I', 0), # loc: 5
('V', 0)] # loc: 6
Test 4¶
Description: Citizens with different levels of interest in getting the vaccine. Not everyone who wants the vaccine will get it.
To run this test in ipython3
:
city = [('S', 0, 0.3), # loc: 0
('S', 0, 0.3), # loc: 1
('S', 0, 0.8), # loc: 2
('S', 0, 0.3), # loc: 3
('S', 0, 0.95), # loc: 4
('I', 0, 1.0), # loc: 5
('S', 0, 0.7)] # loc: 6
sir.vaccinate_city(city, 20170217)
Expected result:
[('S', 0), # loc: 0
('V', 0), # loc: 1
('V', 0), # loc: 2
('S', 0), # loc: 3
('S', 0), # loc: 4
('I', 0), # loc: 5
('V', 0)] # loc: 6
Test 5¶
Description: Uses a different seed
To run this test in ipython3
:
city = [('S', 0, 0.3), # loc: 0
('S', 0, 0.3), # loc: 1
('S', 0, 0.8), # loc: 2
('S', 0, 0.3), # loc: 3
('S', 0, 0.95), # loc: 4
('I', 0, 1.0), # loc: 5
('S', 0, 0.7)] # loc: 6
sir.vaccinate_city(city, 20170218)
Expected result:
[('S', 0), # loc: 0
('S', 0), # loc: 1
('V', 0), # loc: 2
('V', 0), # loc: 3
('V', 0), # loc: 4
('I', 0), # loc: 5
('V', 0)] # loc: 6