Tests Package#

Submodules#

Test Avatar Class#

class game.test_suite.tests.test_avatar.TestAvatar(methodName='runTest')[source]#

Bases: TestCase

Test Avatar Notes:

This class tests the different methods in the Avatar class.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_avatar_json_with_item()[source]#
test_avatar_json_with_none_item()[source]#
test_avatar_set_item()[source]#
test_avatar_set_item_fail()[source]#
test_avatar_set_position()[source]#
test_avatar_set_position_None()[source]#
test_avatar_set_position_fail()[source]#
test_avatar_set_score()[source]#
test_avatar_set_score_fail()[source]#

Test Avatar Inventory#

class game.test_suite.tests.test_avatar_inventory.TestAvatarInventory(methodName='runTest')[source]#

Bases: TestCase

Test Avatar Inventory Notes:

This class tests the different methods in the Avatar class related to the inventory system. This is its own file since the inventory system has a lot of functionality. Look extensively at the different cases that are tested to better understand how it works if there is still confusion.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_avatar_drop_held_item()[source]#
test_avatar_drop_held_item_none()[source]#
test_avatar_pick_up()[source]#
test_avatar_pick_up_extra()[source]#
test_avatar_pick_up_full_inventory()[source]#
test_avatar_pick_up_return_none()[source]#
test_avatar_pick_up_surplus()[source]#
test_avatar_set_inventory()[source]#
test_avatar_set_inventory_fail_1()[source]#
test_avatar_set_inventory_fail_2()[source]#
test_avatar_set_max_inventory_size()[source]#
test_avatar_set_max_inventory_size_fail()[source]#
test_take()[source]#
Take method test:

When this test is performed, it works properly, but because the Item class is used and is very generic, it may not seem to be the case. However, it does work in the end. The first item in the inventory has its quantity decrease to 2 after the take method is executed. Then, the helper method, clean_inventory, consolidates all similar Items with each other. This means that inventory[1] will add its quantity to inventory[0], making it have a quantity of 5; inventory[1] now has a quantity of 4 instead of 7. Then, inventory[2] will add its quantity to inventory[1], making it have a quantity of 7; inventory[2] now has a quantity of 7.

To recap: When the take method is used, it will work properly with more specific Item classes being created to consolidate the same Item object types together

When more subclasses of Item are created, more specific tests can be created if needed.

test_take_fail()[source]#
test_take_none()[source]#

Test Example Class#

class game.test_suite.tests.test_example.TestExample(methodName='runTest')[source]#

Bases: TestCase

Test Example Notes:

This is a mock test class to model tests after. The setUp method MUST be in camel-case for every test file. Everything else can be in snake_case as normal.

The command to run tests is:

python -m game.test_suite.runner

setUp()[source]#

Hook method for setting up the test fixture before exercising it.

test_dict_array()[source]#
test_dict_bool()[source]#
test_dict_integer()[source]#
test_dict_string()[source]#

Test Gameboard Class#

class game.test_suite.tests.test_game_board.TestGameBoard(methodName='runTest')[source]#

Bases: TestCase

Test Gameboard Notes:

This class tests the different methods in the Gameboard class. This file is worthwhile to look at to understand the GamebBoard class better if there is still confusion on it.

This class tests the Gameboard specifically when the map is generated.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_game_board_json()[source]#
test_get_objects_avatar()[source]#
test_get_objects_occupiable_station()[source]#
test_get_objects_occupiable_station_2()[source]#
test_get_objects_station()[source]#
test_get_objects_wall()[source]#
test_locations_fail()[source]#
test_locations_incorrect_fail()[source]#
test_map_size_fail()[source]#
test_seed_fail()[source]#
test_walled_fail()[source]#

Test Gameboard (No Generation)#

class game.test_suite.tests.test_game_board_no_gen.TestGameBoard(methodName='runTest')[source]#

Bases: TestCase

Test Gameboard Without Generation Notes:

This class tests the different methods in the Gameboard class when the map is not generated.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_game_board_json()[source]#
test_generate_map()[source]#
test_locations()[source]#
test_locations_fail_type()[source]#
test_map_size()[source]#
test_map_size_fail()[source]#
test_seed()[source]#
test_seed_fail()[source]#
test_walled()[source]#
test_walled_fail()[source]#

Test Initialization Class#

class game.test_suite.tests.test_initialization.TestInitialization(methodName='runTest')[source]#

Bases: TestCase

Test Avatar Notes:

This class tests the instantiation of different Objects within the project. Recall that every new class created needs a respective ObjectType enum created for it.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_object_init()[source]#

Test Interact Controller Class#

class game.test_suite.tests.test_interact_controller.TestInteractController(methodName='runTest')[source]#

Bases: TestCase

Test Avatar Notes:

This class tests the different methods in the InteractController class.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_interact_dump_item()[source]#
test_interact_item_occupiable_station()[source]#
test_interact_item_station()[source]#
test_interact_nothing()[source]#

Test Inventory Controller Class#

class game.test_suite.tests.test_inventory_controller.TestInventoryController(methodName='runTest')[source]#

Bases: TestCase

Test Inventory Controller Notes:

This class tests the different methods in the Avatar class’ inventory.

check_inventory_item()[source]#
setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_select_slot_0()[source]#
test_select_slot_1()[source]#
test_select_slot_2()[source]#
test_select_slot_3()[source]#
test_select_slot_4()[source]#
test_select_slot_5()[source]#
test_select_slot_6()[source]#
test_select_slot_7()[source]#
test_select_slot_8()[source]#
test_select_slot_9()[source]#
test_with_out_of_bounds()[source]#
test_with_wrong_action_type()[source]#

Test Item Class#

class game.test_suite.tests.test_item.TestItem(methodName='runTest')[source]#

Bases: TestCase

Test Item Notes:

This class tests the different methods in the Item class.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_item_json()[source]#
test_pick_up()[source]#
test_pick_up_surplus()[source]#
test_pick_up_wrong_object_type()[source]#
test_set_durability()[source]#
test_set_durability_fail()[source]#
test_set_durability_none()[source]#
test_set_durability_stack_size_fail()[source]#
test_set_quantity()[source]#
test_set_quantity_fail()[source]#
test_set_quantity_fail_greater_than_0()[source]#
test_set_quantity_fail_stack_size()[source]#
test_set_value()[source]#
test_set_value_fail()[source]#
test_stack_size()[source]#
test_stack_size_fail()[source]#
test_stack_size_fail_quantity()[source]#

Test Master Controller Class#

class game.test_suite.tests.test_master_controller.TestMasterController(methodName='runTest')[source]#

Bases: TestCase

Test Master Controller Notes:

Add tests to this class to tests any new functionality added to the Master Controller.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

Test Movement Controller Class#

class game.test_suite.tests.test_movement_controller.TestMovementControllerIfWall(methodName='runTest')[source]#

Bases: TestCase

Test Movement Controller if Wall Notes:

This class tests the Movement Controller specifically for when there are walls – or other impassable objects – near the Avatar.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_move_down()[source]#
test_move_left()[source]#
test_move_right()[source]#
test_move_up()[source]#

Test Movement Controller with Occupiable Stations the Avatar can Occupy#

class game.test_suite.tests.test_movement_controller_if_occupiable_station_is_occupiable.TestMovementControllerIfOccupiableStationIsOccupiable(methodName='runTest')[source]#

Bases: TestCase

Test Movement Controller if Occupiable Stations are Occupiable Notes:

This class tests the different methods in the Movement Controller class and the Avatar moving onto Occupiable Stations so that the Avatar can occupy it.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_move_down()[source]#
test_move_left()[source]#
test_move_right()[source]#
test_move_up()[source]#

Test Movement Controller with Occupiable Stations#

class game.test_suite.tests.test_movement_controller_if_occupiable_stations.TestMovementControllerIfOccupiableStations(methodName='runTest')[source]#

Bases: TestCase

Test Movement Controller with Occupiable Stations that are Occupied Notes:

This class tests the different methods in the Movement Controller and that the Avatar can’t move onto an Occupiable Station that is occupied by an unoccupiable object (e.g., a Wall or Station object).

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_move_down()[source]#
test_move_down_fail()[source]#
test_move_left()[source]#
test_move_left_fail()[source]#
test_move_right()[source]#
test_move_right_fail()[source]#
test_move_up()[source]#
test_move_up_fail()[source]#

Test Movement Controller with Stations the Avatar Can’t Occupy#

class game.test_suite.tests.test_movement_controller_if_stations.TestMovementControllerIfStations(methodName='runTest')[source]#

Bases: TestCase

Test Movement Controller with Stations Notes:

This class tests the different methods in the Movement Controller and that the Avatar can’t move onto a Station object (an example of an impassable object).

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_move_down()[source]#
test_move_down_fail()[source]#
test_move_left()[source]#
test_move_left_fail()[source]#
test_move_right()[source]#
test_move_right_fail()[source]#
test_move_up_fail()[source]#

Test Movement Controller with Walls#

class game.test_suite.tests.test_movement_controller_if_wall.TestMovementControllerIfWall(methodName='runTest')[source]#

Bases: TestCase

Test Movement Controller with Stations Notes:

This class tests the different methods in the Movement Controller and that the Avatar can’t pass Wall objects.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_move_down()[source]#
test_move_down_fail()[source]#
test_move_left()[source]#
test_move_left_fail()[source]#
test_move_right()[source]#
test_move_right_fail()[source]#
test_move_up()[source]#
test_move_up_fail()[source]#

Test Occupiable Class#

class game.test_suite.tests.test_occupiable.TestOccupiable(methodName='runTest')[source]#

Bases: TestCase

test_is_occupied_by_game_obj() None[source]#
test_is_occupied_by_game_object() None[source]#
test_is_occupied_by_object_type() None[source]#
test_on_station() None[source]#
test_on_top_of_stack() None[source]#
test_place_on_stack() None[source]#
test_remove_form_occupied_by_2_stack() None[source]#
test_remove_from_occupied_by_duplicates() None[source]#
test_remove_from_occupied_by_duplicates_2() None[source]#
test_remove_from_occupied_twice() None[source]#
test_remove_game_obj_from_occupied_by() None[source]#
test_remove_obj_type_from_occupied_by() None[source]#

Test Occupiable Station Class#

class game.test_suite.tests.test_occupiable_station.TestOccupiableStation(methodName='runTest')[source]#

Bases: TestCase

Test Item Notes:

This class tests the different methods in the OccupiableStation class and ensures the objects that occupy them are properly set.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_avatar_occ()[source]#
test_item_occ()[source]#
test_nested_occ_json()[source]#
test_occ_json()[source]#
test_station_occ()[source]#
test_wall_occ()[source]#

Test Place Controller Class#

class game.test_suite.tests.test_place_controller.place_controller(methodName='runTest')[source]#

Bases: TestCase

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_place_down() None[source]#
test_place_left() None[source]#
test_place_right() None[source]#
test_place_up() None[source]#

Test Player Class#

class game.test_suite.tests.test_player.TestPlayer(methodName='runTest')[source]#

Bases: TestCase

Test Player Notes:

This class tests the different methods in the Player class.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_actions()[source]#
test_actions_empty_list()[source]#
test_actions_fail_none()[source]#
test_avatar()[source]#
test_avatar_fail_string()[source]#
test_avatar_none()[source]#
test_functional_fail_int()[source]#
test_functional_false()[source]#
test_functional_true()[source]#
test_object_type()[source]#
test_object_type_fail_int()[source]#
test_object_type_fail_none()[source]#
test_player_json()[source]#
test_team_name()[source]#
test_team_name_fail_int()[source]#
test_team_name_none()[source]#

Test Station Class#

class game.test_suite.tests.test_station.TestStation(methodName='runTest')[source]#

Bases: TestCase

Test Station Example Notes:

This class tests the different methods in the Station Example class. This is used to show how Stations could work and how they can be tested.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_item_occ()[source]#
test_item_occ_fail()[source]#
test_json()[source]#
test_take_action()[source]#

Test Tile Class#

class game.test_suite.tests.test_tile.TestTile(methodName='runTest')[source]#

Bases: TestCase

Test Tile Notes:

This class tests the different methods in the Tile class.

setUp() None[source]#

Hook method for setting up the test fixture before exercising it.

test_avatar_tile()[source]#
test_nested_tile_json()[source]#
test_occupiable_station_tile()[source]#
test_station_tile()[source]#
test_tile_json()[source]#
test_wall_tile()[source]#

Test Utils Class#

class game.test_suite.tests.test_utils.TestUtils(methodName='runTest')[source]#

Bases: TestCase

Test Utils Notes:

This class tests the functionality of the utils.py file.

setUp()[source]#

Hook method for setting up the test fixture before exercising it.

test_diff_len()[source]#
test_double_space_entry()[source]#
test_invalid_input()[source]#
test_long_strings()[source]#
test_long_strings_fail()[source]#
test_valid_input()[source]#

Module contents#