def test_knock_some_pins(): bowling = Bowling() _add_frames(bowling, 10, (6, 0)) expected_score = 60 assert bowling.calculate_score() == expected_score
def test_frame_with_perfect_strike(): bowling = Bowling() _add_frames(bowling, 9, (10, )) _add_frames(bowling, 1, (10, 10, 10)) expected_score = 300 assert bowling.calculate_score() == expected_score
def test_frame_with_spare(): bowling = Bowling() _add_frames(bowling, 9, (1, 9)) _add_frames(bowling, 1, (1, 9, 1)) expected_score = 110 assert bowling.calculate_score() == expected_score
def test_frame_with_strike(): bowling = Bowling() # 10 10 10 10 10 10 10 10 10 000 # 30 30 30 30 30 30 30 20 10 0 _add_frames(bowling, 9, (10, )) _add_frames(bowling, 1, (0, 0)) expected_score = 240 assert bowling.calculate_score() == expected_score
def test_spare_calculation(): """ should print correct result for the last data """ assert_data = { 1: (2, 3, ' ', 5), 2: (5, 4, ' ', 14), 3: (9, '/', ' ', 26), 4: (2, 5, ' ', 33), 5: (3, 2, ' ', 38), 6: (4, 2, ' ', 44), 7: (3, 3, ' ', 50), 8: (4, '/', ' ', 70), 9: ('X', ' ', ' ', 85), 10: (3, 2, ' ', 90) } assert_score = 90 game = Bowling() game.read_csv(filename='../data/test_spare.csv') result = game.calculate_score() assert game.table_content == assert_data assert game.final_score_frame == assert_score
def test_strike_calculation(): """ should print correct result for the last data """ assert_data = { 1: ('X', ' ', ' ', 30), 2: ('X', ' ', ' ', 60), 3: ('X', ' ', ' ', 90), 4: ('X', ' ', ' ', 120), 5: ('X', ' ', ' ', 150), 6: ('X', ' ', ' ', 180), 7: ('X', ' ', ' ', 210), 8: ('X', ' ', ' ', 240), 9: ('X', ' ', ' ', 270), 10: ('X', 'X', 'X', 300) } assert_score = 300 game = Bowling() game.read_csv(filename='../data/test_strike.csv') result = game.calculate_score() assert game.table_content == assert_data assert game.final_score_frame == assert_score
def test_score_calculation(): """ should print correct result for the last data """ assert_data = { 1: ('X', ' ', ' ', 30), 2: ('X', ' ', ' ', 30), 3: ('X', ' ', ' ', 30), 4: None, 5: None, 6: None, 7: None, 8: None, 9: None, 10: None } game = Bowling() assert_score = 30 game.read_csv(filename='../data/test.csv') result = game.calculate_score() assert game.final_score_frame == assert_score assert game.table_content == assert_data
def test_zero_points(): bowling = Bowling() _add_frames(bowling, 10, (0, 0)) assert bowling.calculate_score() == 0