Esempio n. 1
0
def test_toogle2():
    # test if my function toogle is correct in occupying seats
    seater = Seater(size=5)
    seater.seat("occupy 0,0 through 4,4")
    seater.seat("empty 0,0 through 4,4")
    seater.seat("toggle 0,0 through 4,4")
    assert seater.number_occupied() == 25
Esempio n. 2
0
def test_occupy():
    # test if my function occupy is correct
    seater = Seater(size=5)
    seater.seat("occupy 0,0 through 4,4")
    seater.seat("empty 0,0 through 4,4")
    seater.seat("occupy 0,0 through 2,2")
    assert seater.number_occupied() == 9
Esempio n. 3
0
def main(filename=None):
    # here we create the seater object
    seater = Seater(1000)
    
    # and we read the file line by line, feeding each line to the Seater
    with open(filename, 'r') as f:
        for line in f:
            seater.seat(line.strip())
            
    print 'number of occupied seats', seater.number_occupied()
    return
Esempio n. 4
0
def main(filename=None):
    # here we create the seater object
    seater = Seater(1000)

    # and we read the file line by line, feeding each line to the Seater
    with open(filename, 'r') as f:
        for line in f:
            seater.seat(line.strip())

    print('number of occupied seats', seater.number_occupied())
    return
Esempio n. 5
0
def test_toogle2():
    # test if my function toogle is correct in occupying seats
    seater = Seater(size=5)
    seater.seat("occupy 0,0 through 4,4")
    seater.seat("empty 0,0 through 4,4")
    seater.seat("toggle 0,0 through 4,4")
    assert seater.number_occupied()== 25
Esempio n. 6
0
def test_occupy():
    # test if my function occupy is correct
    seater = Seater(size=5)
    seater.seat("occupy 0,0 through 4,4")
    seater.seat("empty 0,0 through 4,4")
    seater.seat("occupy 0,0 through 2,2")
    assert seater.number_occupied()== 9
Esempio n. 7
0
def test_number_occupied():
    # test if my function number_occupied is correct
    seater = Seater(size=5)
    seater.seat("occupy 0,0 through 4,4")
    assert seater.number_occupied() == 25
Esempio n. 8
0
def test_pattern():
    # test the pattern matching is parsing the line correctly
    seater = Seater()
    res = seater.get_cmd("occupy 957,736 through 977,890")
    assert res == ('occupy', 957, 736, 977, 890)
Esempio n. 9
0
def test_all_empty():  #Check if there are any 1 (occupied) in array
    seater = Seater()
    assert 1 in seater.array
Esempio n. 10
0
def test_all_seats_accounted_for():
    seater = Seater()
    total = seater.number_occupied + seater.number_empty
    assert total == len(seater.array) + 1
Esempio n. 11
0
def test_occupy4():
    seater = Seater()
    res = seater.get_cmd("occupy 950,950 through 952,952")
    assert seater.number_occupied() == 9
def test_pattern():
    # test the pattern matching is parsing the line correctly
    seater = Seater()
    res = seater.get_cmd("occupy 957,736 through 977,890")
    assert res == ('occupy', 957, 736, 977, 890)
def test_occupy4():
    seater = Seater()
    res = seater.get_cmd("occupy 950,950 through 952,952")
    assert seater.number_occupied() == 9
Esempio n. 14
0
def test_number_occupied():
    # test if my function number_occupied is correct
    seater = Seater(size=5)
    seater.seat("occupy 0,0 through 4,4")
    assert seater.number_occupied()== 25