def make_move_node(text, move_number, white, wcomment, black, bcomment, mcomment): """Create a mock set of nodes that comprise a Game""" n = MagicMock( move_number = parser.TreeNode(move_number, 0), white = parser.TreeNode(white, 0), wcomment = wcomment, black = parser.TreeNode(black, 0), bcomment = bcomment, mcomment = mcomment) return n
def test_make_game_variations(self): input = '[Site "bmb.io]\n1. e4 (1. d4) e5 {white wins} 1-0' g = Actions().make_game(input, 0, 0, [{'Site': 'bmb.io'}, parser.TreeNode('\n', 0), "", [Move("1.", "e4", "", "", [[Move("1.", "d4", "", "", "", "", "", "", "", "")]], "e5", "", "white wins", [], "")], parser.TreeNode('1-0', 0)]) assert g.tag_pairs['Site'] == "bmb.io" assert g.movetext[0].white.variations[0][0].move_number == 1 assert g.movetext[0].white.variations[0][0].white.san == "d4"
def test_make_game(self): input = '[Site "bmb.io]\n1. e4 e5 {white wins} 1-0' g = Actions().make_game(input, 0, 0, [{'Site': 'bmb.io'}, parser.TreeNode('\n', 0), "", [Move("1.", "e4", "", "", [], "e5", "", "white wins", [], "")], parser.TreeNode('1-0', 0)]) assert g.tag_pairs['Site'] == "bmb.io" assert g.movetext[0].move_number == 1 assert g.movetext[0].white.san == "e4" assert g.movetext[0].black.san == "e5" assert g.movetext[0].black.comment == "white wins" assert g.score.result == "1-0"
def make_nags_move_node(text, move_number, white, wnags, wcomment, black, bnags, bcomment): """Create a mock set of nodes that comprise a Game""" wnagsn = parser.TreeNode(wnags, 0) bnagsn = parser.TreeNode(bnags, 0) wnagsn.elements = [parser.TreeNode(n, 0) for n in wnags.split(' ')] bnagsn.elements = [parser.TreeNode(n, 0) for n in bnags.split(' ')] n = MagicMock( move_number = parser.TreeNode(move_number, 0), white = parser.TreeNode(white, 0), wnags = wnagsn, wcomment = wcomment, black = parser.TreeNode(black, 0), bnags = bnagsn, bcomment = bcomment) return n
def make_nodes(eles): """Create a list of TreeNode's for feeding to the make_ actions""" out = [] for e in eles: out.append(parser.TreeNode(e, 0)) return out