def test_match_rotated(self): tile = puzzle.Tile("0", ["...", "..#", "..."]) other = puzzle.Tile("1", [".x.", "x.x", ".#."]) match_direction, matched_tile = tile.match(other) self.assertEqual(match_direction, puzzle.Direction.EAST) self.assertEqual(matched_tile.tile, other.rotated(90).tile)
def test_match_flipped(self): tile = puzzle.Tile("0", ["y.y", "y.y", "#.."]) other = puzzle.Tile("1", ["x.x", "x.x", "#.."]) match_direction, matched_tile = tile.match(other) self.assertEqual(match_direction, puzzle.Direction.SOUTH) self.assertEqual(matched_tile.tile, other.flipped().tile)
def test_rotation(self): tile = puzzle.Tile("id", ["123", "456", "789"]) rotations = { 0: ["123", "456", "789"], 90: ["741", "852", "963"], 180: ["987", "654", "321"], 270: ["369", "258", "147"] } self.assertEqual( [tile.rotated(degree).tile for degree in rotations.keys()], list(rotations.values()))
def test_border(self): tile = puzzle.Tile("id", ["123", "456", "789"]) self.assertEqual(tile.borders(), ["123", "369", "987", "741"])
def test_delete_border(self): tile = puzzle.Tile("0", ["###", "#.#", "###"]) tile.delete_border() self.assertEqual(tile.tile, ["."])