Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed Test Scripts #340

Open
github-actions bot opened this issue Feb 5, 2022 · 1 comment
Open

Failed Test Scripts #340

github-actions bot opened this issue Feb 5, 2022 · 1 comment

Comments

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

Test Report

Report generated on 05-Feb-2022 at 14:48:50 by pytest-md

Summary

222 tests ran in 1.50 seconds

  • 2 failed
  • 129 passed
  • 90 skipped
  • 1 xfailed

2 failed

test_update_high_score_list.py

test_update_high_score_corrupted_file 0.00s

@pytest.mark.order(8)
    def test_update_high_score_corrupted_file():
        """
        Test whether the system will display error message when existing high score file is corrupted and display the new high score list with only 1 player
        """
        high_score_list_1x1_2 = [
            "--------- HIGH SCORES ---------",
            "Pos Player                Score",
            "--- ------                -----",
            " 1. Never                     1",
            "-------------------------------"
        ]
        gameBoard1x1_1 = [
            [Factory(0,0)]
        ]
    
    
        board1x1Filled_1 = [
            "     A  ",
            "  +-----+",
            " 1| FAC |",
            "  +-----+",
        ]
    
        score_computation1x1_1 = [
            "HSE: 0",
            "FAC: 1 = 1",
            "SHP: 0",
            "HWY: 0",
            "BCH: 0",
            "Total score: 1"
        ]
    
        congratsMsg = ["Congratulations! You made the high score board at position 1!",
                        "Please enter your name (max 20 chars): "]
    
        high_score_json_1 = {
            "board_size": 1,
            "high" : [
                {
                    "name": "HelloWorldHeyDevOps",
                    "score": 16
                }
            ],
            "hell": 'well'
        }
        errorMsg = ["The current high score file is corrupt and a new high score list will be generated."]
    
    
        high_score_Exist = os.path.exists('high_score_1.json')
        if high_score_Exist:
            os.remove('high_score_1.json')
    
        jsonString = json.dumps(high_score_json_1)
        jsonFile = open("high_score_1.json", "w")
        jsonFile.write(jsonString)
        jsonFile.close()
    
    
        set_keyboard_input(["Never", "0"])
    
        defaultBuildingPool = {"HSE":8, "FAC":8, "SHP": 8, "HWY":8, "BCH":8}
    
        test_game = Game(width = 1, height = 1)
        test_game.building_pool = defaultBuildingPool
        test_game.board = gameBoard1x1_1
        test_game.turn_num = 2
>       test_game.start_new_turn()

test_update_high_score_list.py:690: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
classes/game.py:167: in start_new_turn
    self.update_high_score()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <classes.game.Game object at 0x7f0ac81aa910>

    def update_high_score(self):
        """
        Update high score with user's score
    
        Swah Jianoon T01 27th January
        """
        filename = "high_score_{0}.json".format((self.width)*(self.height))
        file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),filename)
        save_data = load_json(file_path)
        save_data["board_size"] = (self.width)*(self.height)
>       high_score_list = save_data["high_scores"]
E       KeyError: 'high_scores'

classes/game.py:409: KeyError

test_show_high_score.py

test_show_high_score_file_corrupted 0.00s

def test_show_high_score_file_corrupted():
        """
        Test whether the system will display error msg and continue working when reading the corrupted saved file.
        """
    
        chosen_city_size_7x1 = [
            "--------- CHOSEN CITY SIZE ---------",
            "Width: 7",
            "Height: 1",
            "------------------------------------"
        ]
        high_score_json_7 = {
            "board_size": 1,
            "high" : [
                {
                    "name": "HelloWorldHeyDevOps",
                    "score": 16
                }
            ],
            "hell": 'well'
        }
    
        errorMsg = ["The current file is corrupt and will therefore be deleted."]
    
    
        high_score_Exist = os.path.exists('high_score_7.json')
        if high_score_Exist:
            os.remove('high_score_7.json')
    
        jsonString = json.dumps(high_score_json_7)
        jsonFile = open("high_score_7.json", "w")
        jsonFile.write(jsonString)
        jsonFile.close()
    
    
        set_keyboard_input(["5","7","1","3","0"])
        with pytest.raises(SystemExit) as e:
>           test_application = main.main()

test_show_high_score.py:329: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
main.py:27: in main
    Game(width=city_size[0], height=city_size[1]).display_high_score()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <classes.game.Game object at 0x7f0ac7bbe070>

    def display_high_score(self):
        """
        Display high score
    
        Swah Jianoon T01 27th January
        """
        filename = "high_score_{0}.json".format((self.width)*(self.height))
        file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),filename)
        save_data = load_json(file_path)
>       high_score_list = save_data["high_scores"]
E       KeyError: 'high_scores'

classes/game.py:444: KeyError

129 passed

test_load_game_refactored.py

test_load_game_no_save 0.00s

test_load_game_empty_board[printEmptyBoard0-3] 0.00s

test_load_game_empty_board[printEmptyBoard1-4] 0.00s

test_load_game_empty_board[printEmptyBoard2-5] 0.00s

test_load_game_with_save_different_board_sizes[printBoard0-3] 0.00s

test_load_game_with_save_different_board_sizes[printBoard1-4] 0.00s

test_load_game_with_save_different_board_sizes[printBoard2-5] 0.00s

test_load_game_with_all_buildings[board0-testPrintBoard0-buildingPool0-buildingHistory0] 0.00s

test_load_game_with_all_buildings[board1-testPrintBoard1-buildingPool1-buildingHistory1] 0.00s

test_load_game_corrupted_save[asdf] 0.00s

test_load_game_corrupted_save[1234] 0.00s

test_load_game_corrupted_save[] 0.00s

test_load_game_corrupted_save[{"board": {"1,1": "PRK"}, "turn_num": 2, "width": 4, "height": 4}] 0.00s

test_load_game_corrupted_save[{"boardasdf": {"0,0": "SHP"}, "turn_num": 2, "width": 4, "height": 4, "randomized_history": {"1": ["SHP", "SHP"], "2": ["BCH", "HWY"]}, "building_pool": {"HSE": 8, "FAC": 8, "SHP": 7, "HWY": 8, "BCH": 8}}] 0.00s

test_update_high_score_list.py

test_update_high_scores_diff_citysize_same_cityarea_samename 0.00s

test_update_high_scores_same_score_lower_position 0.00s

test_update_high_scores_invalid_name 0.00s

test_update_high_scores_never_got_top_10 0.00s

test_update_high_scores_only_got_10_players_in_list 0.00s

test_update_high_scores_display_separately_for_diff_city_area 0.00s

test_build_building_refactored.py

test_build_a_building_SHP 0.00s

test_build_a_building_BCH 0.00s

test_build_a_building_HWY 0.00s

test_build_a_building_FAC 0.00s

test_build_a_building_HSE 0.00s

test_build_a_building_MON 0.00s

test_build_a_building_PRK 0.00s

test_build_a_building_invalid_input[invalidInput0] 0.00s

test_build_a_building_invalid_input[invalidInput1] 0.00s

test_build_a_building_invalid_input[invalidInput2] 0.00s

test_build_a_building_invalid_location 0.00s

test_build_a_building_build_on_existing_building 0.00s

test_choose_building_pool_refactored.py

test_choose_building_pool 0.00s

test_choose_building_pool_invalid_input[invalidInput0-expectedResult0] 0.00s

test_choose_building_pool_invalid_input[invalidInput1-expectedResult1] 0.00s

test_choose_building_pool_invalid_input[invalidInput2-expectedResult2] 0.00s

test_choose_building_pool_out_of_range[invalidInput0-expectedResult0] 0.00s

test_choose_building_pool_out_of_range[invalidInput1-expectedResult1] 0.00s

test_choose_building_pool_out_of_range[invalidInput2-expectedResult2] 0.00s

test_choose_building_pool_out_of_range[invalidInput3-expectedResult3] 0.00s

test_choose_building_pool_out_of_range[invalidInput4-expectedResult4] 0.00s

test_choose_city_size_refactored.py

test_change_city_size_main_menu 0.00s

test_change_city_size_game 0.00s

test_exit_change_city_size[exitInput0-expectedResult0] 0.00s

test_exit_change_city_size[exitInput1-expectedResult1] 0.00s

test_change_city_size_invalid_size 0.00s

test_invalid_input_change_city_size[invalidInput0-expectedResult0] 0.00s

test_invalid_input_change_city_size[invalidInput1-expectedResult1] 0.00s

test_invalid_input_change_city_size[invalidInput2-expectedResult2] 0.00s

test_invalid_input_change_city_size[invalidInput3-expectedResult3] 0.00s

test_invalid_input_change_city_size[invalidInput4-expectedResult4] 0.00s

test_invalid_input_change_city_size[invalidInput5-expectedResult5] 0.00s

test_invalid_input_change_city_size[invalidInput6-expectedResult6] 0.00s

test_game_menu_refactored.py

test_game_menu_display_board 0.00s

test_game_menu_display_options 0.00s

test_game_menu_display_board_options 0.00s

test_game_menu_invalid_input[-1-expectedResult0] 0.00s

test_game_menu_invalid_input[asdf-expectedResult1] 0.00s

test_game_menu_invalid_input[13@!$a-expectedResult2]` 0.00s

test_game_menu_invalid_input[9-expectedResult3] 0.00s

test_game_menu_invalid_input[-expectedResult4] 0.00s

test_game_menu_return_main_menu 0.00s

test_main_menu_exit.py

test_main_menu_exit 0.00s

test_main_menu_refactored.py

test_main_menu_to_game_menu 0.00s

test_main_menu 0.00s

test_main_menu_invalid_input[-1] 0.00s

test_main_menu_invalid_input[asdf] 0.00s

test_main_menu_invalid_input[13@!$a]` 0.00s

test_main_menu_invalid_input[9] 0.00s

test_main_menu_invalid_input[] 0.00s

test_randomized_buildings.py

test_compare_randomized_building_5_turns 0.00s

test_check_randomized_building_in_building_pool 0.00s

test_randomized_building_options_1_building_left 0.00s

test_save_game_refactored.py

test_save_game[input0-4-boardState0-boardStatePlaced0] 0.00s

test_save_game[input1-5-boardState1-boardStatePlaced1] 0.00s

test_save_game[input2-3-boardState2-boardStatePlaced2] 0.00s

test_save_game[input3-4-boardState3-boardStatePlaced3] 0.00s

test_save_game_empty_board 0.00s

test_save_game_existing_save 0.00s

test_see_remaining_buildings.py

test_see_remaining_building_initial_state 0.00s

test_see_remaining_building_after_play 0.00s

test_see_remaining_building_3x3 0.00s

test_see_remaining_building_5x5 0.00s

test_see_remaining_building_after_ending_game_and_starting_new 0.00s

test_see_remaining_building_non_default_pool 0.00s

test_show_high_score.py

test_show_high_scores_options_in_main_menu 0.00s

test_show_high_scores_choice_chosen 0.00s

test_show_high_scores_on_two_diff_city_area 0.00s

test_show_high_scores_empty_list 0.00s

test_view_current_score_refactored.py

test_view_current_score_empty 0.00s

test_view_current_score_bch_center_of_city 0.00s

test_view_current_score_bch_right_or_left_of_city 0.00s

test_view_current_score_fac_single_fac 0.00s

test_view_current_score_fac_4fac 0.00s

test_view_current_score_fac_5fac 0.00s

test_view_current_score_hse_single_hse 0.00s

test_view_current_score_hse_2hse_adjacent 0.00s

test_view_current_score_hse_2bch_center 0.00s

test_view_current_score_hse_2shp_adjacent_to_hse_but_not_to_each_other 0.00s

test_view_current_score_hse_1fac_adjacent 0.00s

test_view_current_score_hse_1fac_adjacent_above 0.00s

test_view_current_score_hse_1fac_adjacent_below 0.00s

test_view_current_score_shp_single_shp 0.00s

test_view_current_score_shp_single_bch_adjacent_not_in_center 0.00s

test_view_current_score_shp_single_bch_adjacent_single_fac_adjacent_bch_not_in_center 0.00s

test_view_current_score_shp_2_bch_adjacent_single_fac_adjacent_bch_not_in_center 0.00s

test_view_current_score_hwy_single_hwy 0.00s

test_view_current_score_hwy_2_hwy_adjacent_on_single_row 0.00s

test_view_current_score_hwy_4_hwy_adjacent_on_single_row 0.00s

test_view_currentscore_hwy_2_hwy_adjacent_on_single_row_1hwy_adjacent_on_different_row 0.00s

test_view_current_score_prk[input0-2-buildingBoard0-currentScore0-actualBoard0-buildingPool0] 0.00s

test_view_current_score_prk[input1-3-buildingBoard1-currentScore1-actualBoard1-buildingPool1] 0.00s

test_view_current_score_prk[input2-4-buildingBoard2-currentScore2-actualBoard2-buildingPool2] 0.00s

test_view_current_score_prk[input3-5-buildingBoard3-currentScore3-actualBoard3-buildingPool3] 0.00s

test_view_current_score_prk[input4-6-buildingBoard4-currentScore4-actualBoard4-buildingPool4] 0.00s

test_view_current_score_prk[input5-7-buildingBoard5-currentScore5-actualBoard5-buildingPool5] 0.00s

test_view_current_score_prk[input6-8-buildingBoard6-currentScore6-actualBoard6-buildingPool6] 0.00s

test_view_current_score_prk[input7-9-buildingBoard7-currentScore7-actualBoard7-buildingPool7] 0.00s

test_view_current_score_mon[input0-2-buildingBoard0-currentScore0-actualBoard0-buildingPool0] 0.00s

test_view_current_score_mon[input1-2-buildingBoard1-currentScore1-actualBoard1-buildingPool1] 0.00s

test_view_current_score_mon[input2-4-buildingBoard2-currentScore2-actualBoard2-buildingPool2] 0.00s

test_view_current_score_mon[input3-5-buildingBoard3-currentScore3-actualBoard3-buildingPool3] 0.00s

test_view_final_score_refactored.py

test_view_final_score[input0-boardState0-1-scoreBoard0-heightWidth0-actualBoard0-boardStateFilled0] 0.00s

test_view_final_score[input1-boardState1-4-scoreBoard1-heightWidth1-actualBoard1-boardStateFilled1] 0.00s

test_view_final_score[input2-boardState2-9-scoreBoard2-heightWidth2-actualBoard2-boardStateFilled2] 0.00s

test_view_final_score[input3-boardState3-16-scoreBoard3-heightWidth3-actualBoard3-boardStateFilled3] 0.00s

test_view_final_score[input4-boardState4-25-scoreBoard4-heightWidth4-actualBoard4-boardStateFilled4] 0.00s

test_view_final_score[input5-boardState5-36-scoreBoard5-heightWidth5-actualBoard5-boardStateFilled5] 0.00s

test_view_final_score[input6-boardState6-16-scoreBoard6-heightWidth6-actualBoard6-boardStateFilled6] 0.00s

90 skipped

test_load_game.py

test_load_game_no_save 0.00s

test_load_game_empty_board 0.00s

test_load_game_with_save_different_board_sizes[printBoard0-3] 0.00s

test_load_game_with_save_different_board_sizes[printBoard1-4] 0.00s

test_load_game_with_save_different_board_sizes[printBoard2-5] 0.00s

test_build_building.py

test_build_a_building 0.00s

test_build_a_building_invalid_input[invalidInput0] 0.00s

test_build_a_building_invalid_input[invalidInput1] 0.00s

test_build_a_building_invalid_input[invalidInput2] 0.00s

test_build_a_building_invalid_location 0.00s

test_build_a_building_build_on_existing_building 0.00s

test_choose_building_pool.py

test_choose_building_pool 0.00s

test_choose_building_pool_invalid_input[invalidInput0-expectedResult0] 0.00s

test_choose_building_pool_invalid_input[invalidInput1-expectedResult1] 0.00s

test_choose_building_pool_invalid_input[invalidInput2-expectedResult2] 0.00s

test_choose_building_pool_out_of_range[invalidInput0-expectedResult0] 0.00s

test_choose_building_pool_out_of_range[invalidInput1-expectedResult1] 0.00s

test_choose_building_pool_out_of_range[invalidInput2-expectedResult2] 0.00s

test_choose_building_pool_out_of_range[invalidInput3-expectedResult3] 0.00s

test_choose_building_pool_out_of_range[invalidInput4-expectedResult4] 0.00s

test_choose_city_size.py

test_change_city_size_main_menu 0.00s

test_change_city_size_game 0.00s

test_exit_change_city_size[exitInput0-expectedResult0] 0.00s

test_exit_change_city_size[exitInput1-expectedResult1] 0.00s

test_change_city_size_invalid_size 0.00s

test_invalid_input_change_city_size[invalidInput0-expectedResult0] 0.00s

test_invalid_input_change_city_size[invalidInput1-expectedResult1] 0.00s

test_invalid_input_change_city_size[invalidInput2-expectedResult2] 0.00s

test_invalid_input_change_city_size[invalidInput3-expectedResult3] 0.00s

test_invalid_input_change_city_size[invalidInput4-expectedResult4] 0.00s

test_game_menu.py

test_game_menu_display_board 0.00s

test_game_menu_display_options 0.00s

test_game_menu_display_board_options 0.00s

test_game_menu_invalid_input[-1-expectedResult0] 0.00s

test_game_menu_invalid_input[asdf-expectedResult1] 0.00s

test_game_menu_invalid_input[13@!$a-expectedResult2]` 0.00s

test_game_menu_invalid_input[9-expectedResult3] 0.00s

test_game_menu_invalid_input[-expectedResult4] 0.00s

test_game_menu_return_main_menu 0.00s

test_main_menu.py

test_main_menu_to_game_menu 0.00s

test_main_menu 0.00s

test_main_menu_invalid_input[-1] 0.00s

test_main_menu_invalid_input[asdf] 0.00s

test_main_menu_invalid_input[13@!$a]` 0.00s

test_main_menu_invalid_input[9] 0.00s

test_main_menu_invalid_input[] 0.00s

test_save_game.py

test_save_game[input0-4-boardState0-boardStatePlaced0] 0.00s

test_save_game[input1-5-boardState1-boardStatePlaced1] 0.00s

test_save_game[input2-3-boardState2-boardStatePlaced2] 0.00s

test_save_game[input3-4-boardState3-boardStatePlaced3] 0.00s

test_save_game_empty_board 0.00s

test_save_game_existing_save 0.00s

test_view_current_score.py

test_view_current_score_empty 0.00s

test_view_current_score_bch_center_of_city 0.00s

test_view_current_score_bch_right_or_left_of_city 0.00s

test_view_current_score_fac_single_fac 0.00s

test_view_current_score_fac_4fac 0.00s

test_view_current_score_fac_5fac 0.00s

test_view_current_score_hse_single_hse 0.00s

test_view_current_score_hse_2hse_adjacent 0.00s

test_view_current_score_hse_2bch_center 0.00s

test_view_current_score_hse_2shp_adjacent_to_hse_but_not_to_each_other 0.00s

test_view_current_score_hse_1fac_adjacent 0.00s

test_view_current_score_shp_single_shp 0.00s

test_view_current_score_shp_single_bch_adjacent_not_in_center 0.00s

test_view_current_score_shp_single_bch_adjacent_single_fac_adjacent_bch_not_in_center 0.00s

test_view_current_score_shp_2_bch_adjacent_single_fac_adjacent_bch_not_in_center 0.00s

test_view_current_score_hwy_single_hwy 0.00s

test_view_current_score_hwy_2_hwy_adjacent_on_single_row 0.00s

test_view_current_score_hwy_4_hwy_adjacent_on_single_row 0.00s

test_view_currentscore_hwy_2_hwy_adjacent_on_single_row_1hwy_adjacent_on_different_row 0.00s

test_view_current_score_prk[input0-2-buildingBoard0-currentScore0-actualBoard0] 0.00s

test_view_current_score_prk[input1-3-buildingBoard1-currentScore1-actualBoard1] 0.00s

test_view_current_score_prk[input2-4-buildingBoard2-currentScore2-actualBoard2] 0.00s

test_view_current_score_prk[input3-5-buildingBoard3-currentScore3-actualBoard3] 0.00s

test_view_current_score_prk[input4-6-buildingBoard4-currentScore4-actualBoard4] 0.00s

test_view_current_score_prk[input5-7-buildingBoard5-currentScore5-actualBoard5] 0.00s

test_view_current_score_prk[input6-8-buildingBoard6-currentScore6-actualBoard6] 0.00s

test_view_current_score_prk[input7-9-buildingBoard7-currentScore7-actualBoard7] 0.00s

test_view_current_score_mon[input0-2-buildingBoard0-currentScore0-actualBoard0] 0.00s

test_view_current_score_mon[input1-2-buildingBoard1-currentScore1-actualBoard1] 0.00s

test_view_current_score_mon[input2-4-buildingBoard2-currentScore2-actualBoard2] 0.00s

test_view_current_score_mon[input3-5-buildingBoard3-currentScore3-actualBoard3] 0.00s

test_view_final_score.py

test_view_final_score[input0-boardState0-1-scoreBoard0-heightWidth0-actualBoard0-boardStateFilled0] 0.00s

test_view_final_score[input1-boardState1-4-scoreBoard1-heightWidth1-actualBoard1-boardStateFilled1] 0.00s

test_view_final_score[input2-boardState2-9-scoreBoard2-heightWidth2-actualBoard2-boardStateFilled2] 0.00s

test_view_final_score[input3-boardState3-16-scoreBoard3-heightWidth3-actualBoard3-boardStateFilled3] 0.00s

test_view_final_score[input4-boardState4-25-scoreBoard4-heightWidth4-actualBoard4-boardStateFilled4] 0.00s

test_view_final_score[input5-boardState5-36-scoreBoard5-heightWidth5-actualBoard5-boardStateFilled5] 0.00s

test_view_final_score[input6-boardState6-16-scoreBoard6-heightWidth6-actualBoard6-boardStateFilled6] 0.00s

1 xfailed

test_update_high_score_list.py

test_update_high_scores_special_character_in_input 0.00s

@github-actions
Copy link
Author

github-actions bot commented Feb 5, 2022

@JianOon Please review with @rlry72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants