Пример #1
0
 def test_put(self):
     world = World()
     location = Location(2, 3)
     world.put_cell(location, CellType.EMPTY)
     self.assertEqual(CellType.EMPTY, world.get_cell(location))
     world.put_cell(location, CellType.FOOD)
     self.assertEqual(CellType.FOOD, world.get_cell(location))
     result = world.put_cell(location, CellType.EMPTY)
     self.assertFalse(result)
Пример #2
0
 def test_update_when_is_not_free(self):
     world = World()
     world.put_cell(Location(1, 1), CellType.FOOD)
     old_value = world.update_cell(Location(1, 1), CellType.POISON)
     self.assertEqual(old_value, CellType.FOOD)
Пример #3
0
 def test_put_when_out_of_range(self):
     world = World()
     with self.assertRaises(Exception):
         world.put_cell(Location(999999, 988888), CellType.POISON)
Пример #4
0
 def test_put_when_not_empty(self):
     world = World()
     world.put_cell(Location(1, 1), CellType.FOOD)
     result = world.put_cell(Location(1, 1), CellType.FOOD)
     self.assertFalse(result)
Пример #5
0
 def test_put_empty_when_empty(self):
     world = World()
     location = Location(1, 1)
     world.put_cell(location, CellType.EMPTY)
     world.put_cell(location, CellType.EMPTY)
Пример #6
0
 def test_put_on_wall(self):
     world = World()
     location = Location(0, 0)
     result = world.put_cell(location, CellType.POISON)
     self.assertFalse(result)
Пример #7
0
 def test_get(self):
     world = World()
     world.put_cell(Location(1, 3), CellType.POISON)
     result = world.get_cell(Location(1, 3))
     self.assertEqual(result, CellType.POISON)