def integration_test(game, coords): results = [] for coord in coords: results.append([("dig", lab.dig(game, *coord)), ("board", deepcopy(game)), ("render", lab.render(game)), ("render/xray", lab.render(game, True)), ("render_ascii", lab.render_ascii(game)), ("render_ascii/xray", lab.render_ascii(game, True))]) return results
def test_integration(self): """ dig, render, and render_ascii on boards """ for t in range(1, 4): with self.subTest(test=t): with open("test_outputs/test_integration%d.json" % t) as f: expected = json.load(f) with open("test_inputs/test_integration%s.json" % t) as f: inputs = json.load(f) results = [] game = inputs['game'] for coord in inputs['coords']: results.append([["dig", lab.dig(game, *coord)], ["board", deepcopy(game)], ["render", lab.render(game)], ["render/xray", lab.render(game, True)], ["render_ascii", lab.render_ascii(game)], ["render_ascii/xray", lab.render_ascii(game, True)]]) self.assertEqual(results, expected)
def test_render(self): """ Testing render on a small board """ with open("test_inputs/test_render.json") as f: inp = json.load(f) result = lab.render(inp) expected = [[" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", "1", "1", "1"], [" ", " ", " ", " ", "1", "2", "_", "_"], ["1", "2", "1", "2", "2", "_", "_", "_"], ["_", "_", "_", "_", "_", "_", "_", "_"], ["_", "_", "_", "_", "_", "_", "_", "_"], ["_", "_", "_", "_", "_", "_", "_", "_"], ["_", "_", "_", "_", "_", "_", "_", "_"], ["_", "_", "_", "_", "_", "_", "_", "_"], ["_", "_", "_", "_", "_", "_", "_", "_"]] self.assertEqual(result, expected)
def ui_render(d): r = lab.render(d["game"], d["xray"]) return r