Example #1
0
    def test_get_worker(self):
        level = self.make_level_simple()
        world = World(level)

        tile = world.get((4, 1))

        self.assertEqual(tile.worker, True)
Example #2
0
    def test_get_dock(self):
        level = self.make_level_simple()
        world = World(level)

        tile = world.get((1, 1))

        self.assertEqual(tile.dock, True)
Example #3
0
    def test_get_box(self):
        level = self.make_level_simple()
        world = World(level)

        tile = world.get((2, 1))

        self.assertEqual(tile.box, True)
Example #4
0
    def test_get_floor(self):
        level = self.make_level_simple()
        world = World(level)

        tile = world.get((1, 1))

        self.assertEqual(tile.wall, False)
Example #5
0
    def test_get_wall(self):
        level = self.make_level_simple()
        world = World(level)

        tile = world.get((0, 0))

        self.assertEqual(tile.wall, True)
Example #6
0
    def test_push_box(self):
        level = self.make_level_simple()
        world = World(level)

        world.push_box((2, 1), (1, 1))

        tile = world.get((1, 1))
        self.assertEqual(tile.box, True)
        self.assertEqual(tile.dock, True)
Example #7
0
    def test_worker_in_dock(self):
        level = self.make_level_with_worker_on_dock()

        world = World(level)

        self.assertIn((2, 2), world.dock_pos)
        self.assertIn((2, 2), world.worker_pos)
Example #8
0
    def test_box_in_dock(self):
        level = self.make_level_with_box_in_dock()

        world = World(level)

        self.assertIn((2, 1), world.box_pos)
        self.assertIn((2, 1), world.dock_pos)
Example #9
0
    def test_atleast_one_worker_error(self):
        level = self.make_level_with_no_worker()

        with self.assertRaisesRegex(ValueError, 'worker not found'):
            World(level)
Example #10
0
    def test_multiple_dock_pos(self):
        level = self.make_level_with_multiple_boxes()

        world = World(level)

        self.assertEqual(world.dock_pos, [(1, 1), (2, 2)])
Example #11
0
    def test_dock_pos(self):
        level = self.make_level_simple()

        world = World(level)

        self.assertEqual(world.dock_pos, [(1, 1)])
Example #12
0
    def test_box_pos(self):
        level = self.make_level_simple()

        world = World(level)

        self.assertEqual(world.box_pos, [(2, 1)])
Example #13
0
    def test_worker_pos(self):
        level = self.make_level_simple()

        world = World(level)

        self.assertEqual(world.worker_pos, [(4, 1)])
Example #14
0
    def test_level_with_no_boxes(self):
        level = self.make_level_with_no_boxes()

        with self.assertRaisesRegex(ValueError, "boxes not found"):
            World(level)
Example #15
0
    def test_invalid_character(self):
        level = ["ABCD"]

        with self.assertRaisesRegex(ValueError, "character not recognized"):
            World(level)
Example #16
0
    def test_unbalanced_box_docks_error(self):
        level = self.make_level_with_unbalanced_box_docks()

        with self.assertRaisesRegex(ValueError, "count mismatch"):
            World(level)