def test06_func_sfcs_bishop_movements_negative_03(self): """ Test script to verify bishop movements to an already occupied location. Illegal move """ logger.info( "\n\n test06_func_sfcs_bishop_movements_negative_03: Test script to verify bishop movements to an already occupied location. Illegal move" ) movement_list = ['Be2'] self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(result['error']['message'] == 'Move cannot be made.', msg='Bishop has made an illegal move. Possible bug') logger.info( 'End of case test06_func_sfcs_bishop_movements_negative_03')
def test06_func_sfcs_rook_movements_negative_02(self): """ Test script to verify rook movements in diagonal shape. Illegal move """ logger.info( "\n\n test06_func_sfcs_rook_movements_negative_02: Test script to verify rook movements in diagonal shape. Illegal move" ) movement_list = ['Re4'] self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(result['error']['message'] == 'Move cannot be made.', msg='Rook has made an illegal move. Possible bug') logger.info('End of case test06_func_sfcs_rook_movements_negative_02')
def test07_sfcs_func_board_invalid_boardstate_negative_07(self): """ Test script to verify board functionality. Script to verify the empty boardstate """ logger.info( "\n\n test07_sfcs_func_board_invalid_boardstate_negative_07: Script to verify the empty board state" ) self.method = "MakeMove" params = {} params['playerState'] = "w" #empty board state params['boardState'] = [] self.initial_state_of_the_board = { "method": self.method, "params": params, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) self.assertTrue(result['error']['message'] == 'Required param (boardState) missing or null', msg="Required param (boardState) is not provided") logger.info( 'End of case test07_sfcs_func_board_invalid_boardstate_negative_07' )
def test01_func_sfcs_pawn_movements_positive(self): """ Test script to verify pawn movements. Single and double movements, killing a pawn and verify the pawn exists or not """ logger.info( "\n\n test01_func_sfcs_pawn_movements_positive: Test script to verify pawn movements. Single and double movements, killing a pawn and verify the pawn exists or not " ) movement_list = ['g5', 'f4', 'b5', 'fxg5', 'g5'] self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue( result['error']['message'] == 'Move cannot be made.', msg="Move shouldnt be made as coin does not exist on the board") logger.info('End of case test01_func_sfcs_pawn_movements_positive')
def setUpClass(self): logger.info("\n\n ============================================ In SFCS TestSFCSFunctionalKing setup Class ============================================") self.config = ConfigUtil().readConfigurationFile() self.move_obj = MakeMove() self.url = self.config['TEST_URL'] self.id = self.config['SESSION_ID'] self.json_rpc = self.config['JSON_RPC'] self.method = self.config['TEST_METHOD'] self.playerState = self.config['PLAYER_STATE'] self.move = "Nc3" self.params = {} ''' Set the initial state of the board and make the first move here ''' self.params = initial_params self.initial_state_of_the_board = {} self.params['playerState'] = self.playerState self.params['move'] = self.move self.initial_state_of_the_board = {"method": self.method, "params": self.params, "id": self.id, "jsonrpc": self.json_rpc} logger.info("SetupClass: Make the initial move on the chess board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result)
def test03_sfcs_func_board_invalid_playerstate_negative_03(self): """ Test script to verify board functionality. Script to verify the invalid player state (W instead of w) """ logger.info( "\n\n test03_sfcs_func_board_invalid_playerstate_negative_03: Script to verify the invalid player states" ) self.method = "MakeMove" #invalid player state self.params['playerState'] = "W" self.initial_state_of_the_board = { "method": self.method, "params": self.params, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) self.assertTrue( result['error']['message'] == 'Could not create board with given inputs.', msg="Should be a BoardError given invalid player state") logger.info( 'End of case test03_sfcs_func_board_invalid_playerstate_negative_03' )
def test10_sfcs_func_board_invalid_location_negative_10(self): """ Test script to verify board functionality. Script to verify an empty move """ logger.info( "\n\n test10_sfcs_func_board_invalid_location_negative_10: Script to verifyempty move " ) self.method = "MakeMove" #invalid player state self.params = {} self.params = initial_params self.params['playerState'] = "w" self.params['playerState'] = self.playerState #invalid move C3 instead of c3 to move the pawn self.params['move'] = "" self.initial_state_of_the_board = { "method": self.method, "params": self.params, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) self.assertTrue(result['error']['message'] == 'Required param (move) missing or null', msg="Required param (move) is not provided") logger.info( 'End of case test10_sfcs_func_board_invalid_location_negative_10')
def test09_sfcs_func_board_invalid_location_negative_09(self): """ Test script to verify board functionality. Script to verify move to a location using invalid coin type (Pawn movement) """ logger.info( "\n\n test09_sfcs_func_board_invalid_location_negative_09: Script to verify move to a location using invalid coin type " ) self.method = "MakeMove" #invalid player state self.params = {} self.params = initial_params self.params['playerState'] = "w" self.params['playerState'] = self.playerState #invalid move C3 instead of c3 to move the pawn self.params['move'] = "C3" self.initial_state_of_the_board = { "method": self.method, "params": self.params, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) self.assertTrue( result['error']['message'] == 'Invalid move string.', msg="Invalid location to move pawn trying to move to a location") logger.info( 'End of case test09_sfcs_func_board_invalid_location_negative_09')
def readConfigurationFile(self, dict_or_object={}): if type(dict_or_object) == type(dict()): kwargs = dict_or_object else: kwargs = dict_or_object.__dict__ try: tb_file = str(os.getenv("testconfig_file")) # Load YAML Value default_dict = yaml.load(open(tb_file)) except: raise RuntimeError( "testconfig_file IS NOT SET IN ENVIRONMENT OR GIVEN CONFIG FILE DOES NOT EXIST. PLEASE SET export testconfig_file='/Location/FileName' " ) default_dict.update(kwargs) TEST_URL = default_dict['TEST_URL'] if "TEST_URL" in default_dict \ else self.__raise_exception("CONFIG FILE DOES NOT HAVE 'TEST_URL' VARIABLE , PLEASE DEFINE LIKE TEST_URL=http://chesstest.solidfire.net:8080/json-rpc") default_dict['TEST_URL'] = kwargs.get('TEST_URL', TEST_URL) default_dict['JSON_RPC'] = default_dict.get('JSON_RPC', "2.0") default_dict['SESSION_ID'] = default_dict.get('SESSION_ID', 1) default_dict['TEST_METHOD'] = default_dict.get('TEST_METHOD', " MakeMove") default_dict['PLAYER_STATE'] = default_dict.get('PLAYER_STATE', "w") logger.info("Reading test config file \n\n") logger.info(default_dict) return default_dict
def test01_func_sfcs_queen_movements_positive_01(self): """ Test script to verify queen movements horizontal and vertical (forward) and get killed """ logger.info("\n\n test01_func_sfcs_queen_movements_positive_01: Test script to verify queen movements horizontal and vertical and get killed ") movement_list = ['Nf6', 'd4', 'h5', 'Qd3' , 'c6', 'Qb3', 'Nd5', 'Qxb7', 'Bxb7'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag= True) logger.info('End of case test01_func_sfcs_queen_movements_positive_01')
def test01_func_sfcs_knight_movements_positive_01(self): """ Test script to verify more than one knight movements (both black and white) and ultimately kill a black knight """ logger.info("\n\n test01_func_sfcs_knight_movements_positive: Test script to verify more than one knight movements (both black and white) and ultimately kill a black knight ") movement_list = ['Nc6', 'Na4', 'Nc4', 'Ne5' , 'Nxe5', 'Ng4'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag= False) self.assertTrue(result['error']['message'] == 'Move cannot be made.', msg= "Move shouldn't be made as coin does not exist on the board") logger.info('End of case test01_func_sfcs_knight_movements_positive')
def test06_func_sfcs_knight_two_pieces_same_space_negative03(self): """ Test script to verify two same Knight pieces are occupying same location """ logger.info("\n\n test06_func_sfcs_knight_two_pieces_same_space_negative03: Test script to verify more than one knight movements (both black and white), issue backward movements") movement_list = ['b6', 'e3', 'b4', 'Ne2', 'h6' , 'Nc3'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(result['error']['message']=='Move cannot be made.', msg='Knight occupying location of another knight of the same player') logger.info('End of case test06_func_sfcs_knight_two_pieces_same_space_negative03')
def test01_func_sfcs_king_movements_positive(self): """ Test script to verify king movements.- Move the king in all directions one step """ logger.info("\n\n test01_func_sfcs_pawn_movements_positive: Move the king in all directions one step ") movement_list = ['Nf6', 'f4','c5', 'd4', 'd6', 'Nb5', 'Nc6', 'c4', 'Bf5', 'e4', 'Bg6', 'g4', 'h6', 'Qa4', 'Bxe4', 'Bh3', 'a6', 'Ke2', 'axb5', 'Ke1', 'bxa4', 'Kf1', 'Bxh1', 'Ke1', 'Nxd4', 'Kd2', 'Qd7', 'Kc1'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag = False) self.assertTrue(result['error']['message'] == 'Move cannot be made.', msg= "Move shouldnt be made as coin does not exist on the board") logger.info('End of case test01_func_sfcs_pawn_movements_positive')
def test05_func_sfcs_knight_move_invalid_location_negative02(self): """ Test script to verify movement to an invalid location """ logger.info("\n\n test05_func_sfcs_knight_move_invalid_location_negative02: Test script to verify more than one knight movements (both black and white), issue backward movements") movement_list = ['Na9', 'Nh10', 'Na-1', 'nc3'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(result['error']['message']=="Invalid move string.", msg='Invalid move done on the chess board by Knight') logger.info('End of case test05_func_sfcs_knight_move_invalid_location_negative02')
def setUpClass(self): logger.info( "\n\n ============================================ In SFCS TestSFCSFunctionalBoard setup Class ============================================" ) self.move_obj = MakeMove() self.config = ConfigUtil().readConfigurationFile() self.url = self.config['TEST_URL'] self.id = self.config['SESSION_ID'] self.json_rpc = self.config['JSON_RPC'] self.playerState = self.config['PLAYER_STATE'] self.move = "Nc3" self.params = {} ''' Set the initial state of the board and make the first move here ''' self.params = initial_params self.initial_state_of_the_board = {} self.params['playerState'] = self.playerState self.params['move'] = self.move
def make_iter_moves_for_game_action(self, state, move, movement_list, url, error_flag=True): """ This is a helper method to invoke multiple calls to emulate chess moves by iterating make_move() method Parameters: state (tuple) : a tuple of next player state, game state(if any) and present board state state_of_the_board (dict) : state of the board movement_list (list) : list which contains the chess coin movements url (str) : Endpoint to access error_flag(boolean) : Set/unset the error flag if the error has to be returned to capture negative scenarios. Else it will assert a failure Returns: should return the game state. """ (player_state, game_state, board_state) = state logger.debug("player state: %s" % player_state) for i in range(len(movement_list)): logger.debug("%s Moving to :%s" % (player_state, movement_list[i])) b_state = {} b_state['boardState'] = board_state b_state['move'] = movement_list[i] b_state['playerState'] = player_state move['params'] = b_state result = self.make_move(move, url) if 'error' in result: logger.error("Found error in MakeMove: %s" % result) if not error_flag: return result else: assert (False) else: (player_state, game_state, board_state) = self.get_states_from_last_move(result) if game_state != '': logger.info("Found a game state: %s" % game_state) return game_state
def test01_smoke_sfcs_checkmate_end_to_end(self): """ Test script to verify checkmate scenario by emulating multiple coin movements on a chess board """ logger.info( "\n\n test01_smoke_sfcs_checkmate_end_to_end: Test script to verify checkmate scenario by emulating multiple coin movements on a chess board" ) movement_list = ['e5', 'Ke2', 'd5', 'Kd3', 'Qf6', 'Qe2', 'e4'] self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } self.game_state = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url) self.assertTrue(self.game_state == 'checkmate', msg='Checkmate not achieved using selected moves') logger.info('End of case test01_smoke_sfcs_checkmate_end_to_end')
def test02_func_sfcs_pawn_movements_illegal_negative_01(self): """ Test script to verify illegal pawn movements - 3 steps forward """ logger.info( "\n\n test02_func_sfcs_pawn_movements_illegal_negative01: Test script to verify illegal pawn movements " ) logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) movement_list = ['g3'] self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(result['error']['message'] == 'Move cannot be made.', msg="Illegal move made by the pawn") logger.info( 'End of case test02_func_sfcs_pawn_movements_illegal_negative_01')
def test03_smoke_scfs_check_end_to_end(self): """ Test script to verify a check scenario by emulating multiple coin movements on a chess board """ logger.info( "\n\n test03_smoke_scfs_check_end_to_end: Test script to verify a check scenario by emulating multiple coin movements on a chess board" ) movement_list = ['Nf6', 'Bb5', 'h5', 'Bxd7'] logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } self.game_state = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url) self.assertTrue(self.game_state == 'check', msg='check not achieved using selected moves') logger.info("End of case test03_smoke_scfs_check_end_to_end")
def test02_smoke_scfs_stalemate_end_to_end(self): """ Test script to verify stalemate scenario by emulating multiple coin movements on a chess board """ logger.info( "\n\n test02_smoke_scfs_stalemate_end_to_end: Test script to verify stalemate scenario by emulating multiple coin movements on a chess board" ) movement_list = [ 'a5', 'Qh5', 'Ra6', 'Qxa5', 'h5', 'Qxc7', 'Rah6', 'h4', 'f6', 'Qxd7', 'Kf7', 'Qxb7', 'Qd3', 'Qxb8', 'Qh7', 'Qxc8', 'Kg6', 'Qe6' ] logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) self.next_move = { "method": self.method, "params": {}, "id": self.id, "jsonrpc": self.json_rpc } self.game_state = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url) self.assertTrue(self.game_state == 'stalemate', msg='Stalemate not achieved using selected moves') logger.info("End of case test02_smoke_scfs_stalemate_end_to_end")
def test02_sfcs_func_board_invalid_method_negative_02(self): """ Test script to verify board functionality. Script to verify the board when an method is passed as empty """ logger.info( "\n\n test02_sfcs_func_board_invalid_method_negative_02: Script to verify the board when an method is passed as empty" ) #empty method self.method = "" self.initial_state_of_the_board = { "method": self.method, "params": self.params, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) self.assertTrue(result['error']['message'] == 'no method specified', msg="empty method passed illegally to invoke a move") logger.info( 'End of case test02_sfcs_func_board_invalid_method_negative_02')
def test01_sfcs_func_board_invalid_method_negative_01(self): """ Test script to verify board functionality. Script to verify the board when an invalid method is been passed """ logger.info( "\n\n test01_sfcs_func_board_invalid_method_negative_01: Script to verify the board when an invalid method is been passed " ) #invalid method self.method = "makemove" self.initial_state_of_the_board = { "method": self.method, "params": self.params, "id": self.id, "jsonrpc": self.json_rpc } result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) self.assertTrue( result['error']['message'] == 'Unknown method: makemove', msg="unknown method passed illegally to invoke a move") logger.info( 'End of case test01_sfcs_func_board_invalid_method_negative_01')
def make_move(self, state_of_the_board, url): """ This method invokes a REST API POST request call to the url Parameters: state_of_the_board (dict): Present state of the chess board in dictionary format url (str) : Endpoint to access Returns: response the board state in a dictionary format. returns None if nothing is executed """ logger.debug( "Calling method make_move, invokes a REST API POST request call to the url" ) headers = json.dumps({'content-type': 'application/json'}) state_of_the_board = json.dumps(state_of_the_board) headers = json.loads(headers) logger.debug("URL is : %s\n\n" % (url)) logger.debug("PAYLOAD is : %s\n\n" % state_of_the_board) try: resp = requests.post(url=url, headers=headers, data=state_of_the_board) if 'error' in resp.json(): response = resp.json() logger.info("\n\n Error in response: %s" % response) return response elif 'result' in resp.json(): response = resp.json() status = resp.status_code logger.info("\n\n Status Obtained : %s" % status) logger.info("\n\n Response : %s" % response) logger.info("\n\n") return response else: return None except Exception as e: logger.error(e) return e
def test04_func_sfcs_queen_movements_positive_04(self): """ Test script to verify queen movements backwards in diagonal, horizontal and vertical. """ logger.info("\n\n test04_func_sfcs_queen_movements_positive_04: Test script to verify queen movements backwards in diagonal, horizontal and vertical.") movement_list = [ 'e5', 'd4', 'd5' , 'Qd3', 'Nd7', 'Qf5', 'Nh6', 'Qf3', 'Nb6', 'Qh5', 'Be6', 'Qh4', 'Qxh4', 'Nf3', 'Qd8'] logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag= True) logger.info('End of case test04_func_sfcs_queen_movements_positive_04')
def test03_func_sfcs_kill_using_king_positive(self): """ Test script to verify king movements.- Kill a coin using king """ logger.info("\n\n test03_func_sfcs_kill_using_king_positive: Test script to verify king movements.- Kill a coin using king") logger.info("SetupClass: Make the initial move on the chess board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) movement_list = [ 'a6', 'f4', 'Nc6', 'f5', 'g6', 'f6', 'd6', 'fxe7', 'Kxe7'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url) logger.info('End of case test03_func_sfcs_kill_using_king_positive')
def test02_func_sfcs_king_movements_positive(self): """ Test script to verify king movements.- Move the coins until a check is called by the opponent """ logger.info("\n\n test02_func_sfcs_king_movements_positive: Test script to verify king movements.- Move the coins until a check is called by the opponent ") logger.info("SetupClass: Make the initial move on the chess board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) movement_list = [ 'e5', 'd4', 'e4', 'Qd2', 'Qe7', 'Nxe4', 'Qxe4', 'f3', 'Qg6', 'Qc3', 'Qc6', 'Kd2', 'd6', 'Kd3', 'Ne7', 'd5', 'Nxd5', 'Qd4', 'f5', 'Qxd5', 'Qxd5'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag = False) self.assertTrue(result == 'check', msg= "Check call not found on the king") logger.info('End of case test02_func_sfcs_king_movements_positive')
def test03_func_sfcs_queen_movements_positive_03(self): """ Test script to verify queen movements killing moves in diagonal, horizontal and vertical . Issue check """ logger.info("\n\n test03_func_sfcs_queen_movements_positive_03: Test script to verify queen movements killing moves in diagonal, horizontal and vertical . Issue check") movement_list = [ 'Nf6', 'd4', 'h5' , 'e4', 'c6', 'd5', 'd6', 'Qd3', 'Bd7', 'dxc6', 'Qb6', 'c7', 'Ng4', 'Qxd6', 'Qxf2'] logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} self.game_state = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag= False) self.assertTrue(self.game_state == 'check', msg= "Queen couldnt issue a check") logger.info('End of case test03_func_sfcs_queen_movements_positive_03')
def test09_func_sfcs_king_illegal_moves_negative_06(self): """ Test script to verify illegal king movements - invalid location backwards """ logger.info("\n\n test09_func_sfcs_king_illegal_moves_negative_06: Test script to verify illegal king movements ") logger.info("SetupClass: Make the initial move on the chess board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) movement_list = [ 'Ke9'] self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag = False) self.assertTrue(result['error']['message'] == 'Invalid move string.', msg= "Illegal move made by the pawn") logger.info('End of case test09_func_sfcs_king_illegal_moves_negative_06')
def test03_func_sfcs_knight_back_movement_positive_03(self): """ Test script to verify more than one knight movements (both black and white), issue backward movements """ logger.info("\n\n test03_func_sfcs_knight_back_movement_positive: Test script to verify more than one knight movements (both black and white), issue backward movements") movement_list = ['b5', 'Nh6', 'b4', 'Nb1', 'f4' , 'Nf2', 'h6','Nf2'] logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} result = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(result['error']['message']=='Move cannot be made.', msg='Knight Trying to move back to an already moved location') logger.info('End of case test02_func_sfcs_knight_movements_positive')
def test02_func_sfcs_knight_movements_positive_02(self): """ Test script to verify more than one knight movements (both black and white), issue a check """ logger.info("\n\n test02_func_sfcs_knight_movements_positive: Test script to verify more than one knight movements (both black and white) and ultimately kill a black knight ") movement_list = ['b6', 'Nh3', 'Nh6', 'Nf4', 'Ng4' , 'Ng6', 'Nf2', 'Nxf8', 'Nd3'] logger.info("Make initial move on the board") result = self.move_obj.make_move(self.initial_state_of_the_board, self.url) (self.player_state, self.game_state, self.board_state) = self.move_obj.get_states_from_last_move(result) self.next_move = {"method": self.method, "params":{}, "id": self.id, "jsonrpc": self.json_rpc} self.game_state = self.move_obj.make_iter_moves_for_game_action( (self.player_state, self.game_state, self.board_state), self.next_move, movement_list, self.url, error_flag=False) self.assertTrue(self.game_state=='check', msg='check not achieved using selected moves') logger.info('End of case test02_func_sfcs_knight_movements_positive')