Tests for Task 2: Advance person at location

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

$ py.test -xvk 'advance'

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

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 1

Description: Susceptible middle person with an infected right neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 2

Description: Susceptible middle person with two infected neighbors gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 3

Description: Susceptible middle person with no infected neighbors does not get infected.

To run this test in ipython3 :

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

Expected result: ('S', 1)

Test 4

Description: Susceptible first person with an infected left neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 5

Description: Susceptible first person with an infected right neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 6

Description: Susceptible first person with two infected neighbors gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 7

Description: Susceptible first person with no infected neighbors does not get infected.

To run this test in ipython3 :

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

Expected result: ('S', 1)

Test 8

Description: Susceptible last person with an infected right neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 9

Description: Susceptible last person with an infected left neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 10

Description: Susceptible last person with two infected neighbors gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 11

Description: Susceptible last person with no infected neighbors does not get infected.

To run this test in ipython3 :

city = [('R', 1),    # loc: 0
        ('R', 1500),    # loc: 1
        ('S', 10)]    # loc: 2
sir.advance_person_at_location(city, 2, 3)

Expected result: ('S', 11)

Test 12

Description: Person infected for fewer than days_contagtious - 1. Person stays infected ith and their number of days infected increases by one.

To run this test in ipython3 :

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

Expected result: ('I', 2)

Test 13

Description: Person infected for exactly days_contagtious - 1. Person converts to recovers with zero days.

To run this test in ipython3 :

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

Expected result: ('R', 0)

Test 14

Description: Person infected for fewer than days_contagtious - 1. Person stays infected ith and their number of days infected increases by one. Number of days is large.

To run this test in ipython3 :

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

Expected result: ('I', 1501)

Test 15

Description: Person infected for exactly days_contagtious - 1. Person converts to recovers with zero days. Number of days is large.

To run this test in ipython3 :

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

Expected result: ('R', 0)

Test 16

Description: Person is recovered. Their number of days is increased by one.

To run this test in ipython3 :

city = [('I', 2),    # loc: 0
        ('I', 1500),    # loc: 1
        ('R', 0)]    # loc: 2
sir.advance_person_at_location(city, 2, 2000)

Expected result: ('R', 1)

Test 17

Description: Susceptible middle person in a slightly larger city. Left neighbor is infected, so the middle person gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 18

Description: Susceptible middle person in a slightly larger city. Right neighbor is infected, so the middle person gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 19

Description: Susceptible middle person in a slightly larger city. Both neighbors are infected, so the person gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 20

Description: Susceptible middle person in a slightly larger city. Neighter neighbor is infected, so the person stays susceptible.

To run this test in ipython3 :

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

Expected result: ('S', 1501)

Tests for Task 6-2: add vaxxed people

This section describes tests for Task 2 that include vaccinated people. Work through these tests after you have completed Tasks 1-5.

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

$ py.test -xvk advance --runvax

Test 0

Description: Middle person with two vaxxed neighbors. This person stays susceptible with an increase in the number of days in that state.

To run this test in ipython3 :

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

Expected result: ('S', 1)

Test 1

Description: Susceptible middle person with an infected left neighbor and a vaxxed right neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 2

Description: Susceptible middle person with an infected right neighbor and a vaxxed left neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 3

Description: First person with two vaxxed neighbors. This person stays susceptible with an increase in the number of days in that state.

To run this test in ipython3 :

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

Expected result: ('S', 21)

Test 4

Description: Susceptible first person with an infected left neighbor and a vaxxed right neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 5

Description: Susceptible first person with an infected right neighbor and a vaxxed left neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 6

Description: Last person with two vaxxed neighbors. This person stays susceptible with an increase in the number of days in that state.

To run this test in ipython3 :

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

Expected result: ('S', 12)

Test 7

Description: Susceptible last person with an infected right neighbor and a vaxxed left neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 8

Description: Susceptible last person with an infected left neighbor and a vaxxed right neighbor gets infected.

To run this test in ipython3 :

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

Expected result: ('I', 0)

Test 9

Description: Middle person with two vaxxed neighbors. This person stays susceptible with an increase in the number of days in that state. Slightly larger city.

To run this test in ipython3 :

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

Expected result: ('S', 1501)