def setup(self): """ Setup the test case """ self.floor_rock = 1 self.floor_brick = 2 self.wall_empty = 3 self.wall_ground = 4 self.level = Level((10, 15), floor_type = FLOOR_NATURAL, wall_type = self.wall_empty) self.level.floor[5][5] = FLOOR_CONSTRUCTED self.level.floor[6][5] = FLOOR_CONSTRUCTED self.level.floor[7][5] = FLOOR_CONSTRUCTED self.level.floor[0][0] = FLOOR_CONSTRUCTED self.level.floor[10][0] = FLOOR_CONSTRUCTED self.level.floor[0][15] = FLOOR_CONSTRUCTED self.level.floor[10][15] = FLOOR_CONSTRUCTED self.level.walls[2][2] = WALL_NATURAL self.level.walls[5][5] = WALL_NATURAL self.config = ReplacingDecoratorConfig(['crypt'], {FLOOR_NATURAL: self.floor_rock, FLOOR_CONSTRUCTED: self.floor_brick}, {WALL_NATURAL: self.wall_ground} ) self.decorator = ReplacingDecorator(self.config)
class TestLevelDecorator(): """ Tests for LevelDecorator """ def __init__(self): """ Default constructor """ self.level = None self.config = None self.decorator = None self.floor_rock = None self.floor_brick = None self.wall_empty = None self.wall_ground = None def setup(self): """ Setup the test case """ self.floor_rock = 1 self.floor_brick = 2 self.wall_empty = 3 self.wall_ground = 4 self.level = Level((10, 15), floor_type = FLOOR_NATURAL, wall_type = self.wall_empty) self.level.floor[5][5] = FLOOR_CONSTRUCTED self.level.floor[6][5] = FLOOR_CONSTRUCTED self.level.floor[7][5] = FLOOR_CONSTRUCTED self.level.floor[0][0] = FLOOR_CONSTRUCTED self.level.floor[10][0] = FLOOR_CONSTRUCTED self.level.floor[0][15] = FLOOR_CONSTRUCTED self.level.floor[10][15] = FLOOR_CONSTRUCTED self.level.walls[2][2] = WALL_NATURAL self.level.walls[5][5] = WALL_NATURAL self.config = ReplacingDecoratorConfig(['crypt'], {FLOOR_NATURAL: self.floor_rock, FLOOR_CONSTRUCTED: self.floor_brick}, {WALL_NATURAL: self.wall_ground} ) self.decorator = ReplacingDecorator(self.config) def test_replacing_ground(self): """ Test that proto ground is replaced with given tiles """ self.decorator.decorate_level(self.level) assert_that(self.level.floor[5][5], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[6][5], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[7][5], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[0][0], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[10][0], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[0][15], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[10][15], is_(equal_to(self.floor_brick))) assert_that(self.level.floor[2][2], is_(equal_to(self.floor_rock))) def test_replacing_walls(self): """ Test that proto walls are replaced with given tiles """ self.decorator.decorate_level(self.level) assert_that(self.level.walls[2][2], is_(equal_to(self.wall_ground))) assert_that(self.level.walls[5][5], is_(equal_to(self.wall_ground)))