def test_should_rescue_captive(self): captive = Captive() captive.position = mock.Mock() mock_space = mock.Mock() mock_space.is_captive.return_value = True self.rescue.space = mock.Mock(return_value=mock_space) self.rescue.unit = mock.Mock(return_value=captive) self.warrior.earn_points = mock.Mock() self.rescue.perform() self.assertEqual(None, captive.position) self.warrior.earn_points.assert_called_once_with(20)
def setUp(self): self.floor = Floor() self.floor.width = 2 self.floor.height = 3 self.captive = Captive() self.floor.add(self.captive, 0, 0) self.explode = Explode(self.captive)
class TestWithCaptive(TestSpace): def setUp(self): super(TestWithCaptive, self).setUp() self.captive = Captive() self.floor.add(self.captive, 0, 0) self.space = self.floor.space(0, 0) def test_should_be_captive(self): self.assertTrue(self.space.is_captive()) def test_should_not_be_enemy(self): self.assertFalse(self.space.is_enemy()) def test_should_be_ticking_if_captive_has_time_bomb(self): self.captive.add_abilities('explode_') self.assertTrue(self.space.is_ticking()) def test_should_not_be_ticking_if_captive_does_not_have_time_bomb(self): self.assertFalse(self.space.is_ticking())
class TestCaptive(unittest.TestCase): def setUp(self): self.captive = Captive() def test_should_have_1_max_health(self): self.assertEqual(self.captive.max_health, 1) def test_should_appear_as_C_on_map(self): self.assertEqual(self.captive.character, "C") def test_should_be_bound_by_default(self): self.assertTrue(self.captive.is_bound()) def test_should_not_have_explode_ability_by_default(self): self.assertNotIn('explode_', self.captive.abilities)
def setUp(self): self.captive = Captive()
def setUp(self): super(TestWithCaptive, self).setUp() self.captive = Captive() self.floor.add(self.captive, 0, 0) self.space = self.floor.space(0, 0)