Tests for Task 1: Has an infected neighbor

This page describes the tests for Task 1. 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 1, run the following command at the Linux command-line:

$ py.test -xvk has

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: Middle person with an infected left neighbor.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('S', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: True

Test 1

Description: Middle person with an infected right neighbor.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('I', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: True

Test 2

Description: Middle person with two infected neighbors.

To run this test in ipython3 :

city = [('I', 1),    # loc: 0
        ('S', 0),    # loc: 1
        ('I', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: True

Test 3

Description: Middle person with no infected neighbors.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('R', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: False

Test 4

Description: Middle person with a right infected neighbor. City has more than three people.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('I', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 5

Description: Middle person with a left infected neighbor. City has more than three people.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('I', 200),    # loc: 1
        ('S', 0),    # loc: 2
        ('R', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 6

Description: Middle person with two infected neighbors, City has more than three people.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('I', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('I', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 7

Description: Middle person with no infected neighbors. City has more than three people.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('R', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: False

Test 8

Description: First person with a infected left (wrap-around) neighbor.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('I', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: True

Test 9

Description: First person with an infected right neighbor.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('I', 1),    # loc: 1
        ('S', 20),    # loc: 2
        ('S', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: True

Test 10

Description: First person with two infected neighbors.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('I', 1),    # loc: 1
        ('S', 0),    # loc: 2
        ('I', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: True

Test 11

Description: First person with no infected neighbors.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('S', 1),    # loc: 1
        ('S', 0),    # loc: 2
        ('S', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: False

Test 12

Description: Last person with an infected left neighbor.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('I', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: True

Test 13

Description: Last person with an infected right (wrap-around) neighbor.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: True

Test 14

Description: Last person with two infected neighbors.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('I', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: True

Test 15

Description: Last person with no infected neighbors.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('R', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: False

Test 16

Description: Middle person in a larger city with no infected neighbors.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('I', 1),    # loc: 1
        ('I', 0),    # loc: 2
        ('I', 1),    # loc: 3
        ('R', 0),    # loc: 4
        ('S', 1),    # loc: 5
        ('R', 0),    # loc: 6
        ('I', 1),    # loc: 7
        ('I', 0),    # loc: 8
        ('I', 1),    # loc: 9
        ('R', 0),    # loc: 10
        ('I', 1),    # loc: 11
        ('I', 0),    # loc: 12
        ('I', 1),    # loc: 13
        ('I', 2),    # loc: 14
        ('I', 1),    # loc: 15
        ('I', 0),    # loc: 16
        ('I', 1),    # loc: 17
        ('S', 3),    # loc: 18
        ('S', 1)]    # loc: 19
sir.has_an_infected_neighbor(city, 5)

Expected result: False

Test 17

Description: Last person in a larger city with an infected neighbor

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('I', 1),    # loc: 1
        ('I', 0),    # loc: 2
        ('I', 1),    # loc: 3
        ('R', 0),    # loc: 4
        ('S', 1),    # loc: 5
        ('R', 0),    # loc: 6
        ('I', 1),    # loc: 7
        ('I', 0),    # loc: 8
        ('I', 1),    # loc: 9
        ('R', 0),    # loc: 10
        ('I', 1),    # loc: 11
        ('I', 0),    # loc: 12
        ('I', 1),    # loc: 13
        ('I', 2),    # loc: 14
        ('I', 1),    # loc: 15
        ('I', 0),    # loc: 16
        ('I', 1),    # loc: 17
        ('S', 3),    # loc: 18
        ('S', 1)]    # loc: 19
sir.has_an_infected_neighbor(city, 19)

Expected result: True

Tests for Task 6, Part 2: Adding vaccinated people

This section describes tests for Part 2, Task 6, which includes vaccinated people. Work through these tests after you have completed Part 1 (Tasks 1-5).

To run the tasks for Part 2, Task 6, run the following command at the Linux command-line:

$ py.test -xvk has --runvax

Test 0

Description: Middle person with an infected left neighbor and a vaxxed right neighbor.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('V', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: True

Test 1

Description: Middle person with an infected right neighbor and a vaxxed left neighbor.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('I', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: True

Test 2

Description: Middle person two vaxxed neighbors.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('V', 0)]    # loc: 2
sir.has_an_infected_neighbor(city, 1)

Expected result: False

Test 3

Description: Middle person with an infected right neighbor and a vaxxed left neighbor. City has more than three people.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('V', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('I', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 4

Description: Middle person with an infected left neighbor and a vaxxed right neighbor. City has more than three people.

To run this test in ipython3 :

city = [('R', 0),    # loc: 0
        ('I', 200),    # loc: 1
        ('S', 0),    # loc: 2
        ('V', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 5

Description: Middle person with two vaxxed neighbors. City has more than three people.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('V', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('V', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: False

Test 6

Description: First person with an infected left (wrap-around) neighbor and a vaxxed right neighbor. City has more than three people.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('V', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('I', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: True

Test 7

Description: First person with an infected right neighbor and a vaxxed left (wrap-around) neighbor. City has more than three people.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('I', 0),    # loc: 1
        ('S', 0),    # loc: 2
        ('V', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: True

Test 8

Description: First person with two vaxxed neighbors. City has more than three people.

To run this test in ipython3 :

city = [('S', 0),    # loc: 0
        ('V', 1),    # loc: 1
        ('V', 0),    # loc: 2
        ('V', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: False

Test 9

Description: Last person with an infected right (wrap-around) neighbor and a vaxxed left neighbor. City has more than three people.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('V', 0),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: True

Test 10

Description: Last person with an infected left neighbor and a vaxxed right (wrap-around) neighbor. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('I', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: True

Test 11

Description: Last person both neighbors are vaxxed. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('V', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: False

Test 12

Description: Vaxxed person with two susceptible neighbors. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('V', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: False

Test 13

Description: Vaxxed person with infected left neighbor. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('I', 0),    # loc: 1
        ('V', 100),    # loc: 2
        ('S', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 14

Description: Vaxxed person with infected right neighbor. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('S', 0),    # loc: 1
        ('V', 100),    # loc: 2
        ('I', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 15

Description: Vaxxed person with two infected neighbors. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('I', 0),    # loc: 1
        ('V', 100),    # loc: 2
        ('I', 0)]    # loc: 3
sir.has_an_infected_neighbor(city, 2)

Expected result: True

Test 16

Description: First person with infected left (wrap-around) neighbor. City has more than three people.

To run this test in ipython3 :

city = [('V', 0),    # loc: 0
        ('V', 1),    # loc: 1
        ('V', 0),    # loc: 2
        ('I', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 0)

Expected result: True

Test 17

Description: Last person with infected right (wrap-around) neighbor. City has more than three people.

To run this test in ipython3 :

city = [('I', 0),    # loc: 0
        ('V', 1),    # loc: 1
        ('V', 0),    # loc: 2
        ('V', 1)]    # loc: 3
sir.has_an_infected_neighbor(city, 3)

Expected result: True