def test_is_complete_returns_true_if_and_only_if_the_elapsed_time_is_greater_than_or_equal_to_the_buildings_build_time(self): # noqa dummy_building = MagicMock() dummy_building.build_time = 2.0 dummy_unit = MagicMock() construct = Construct(dummy_building) construct.elapsed_time = 1.9 self.assertFalse(construct.is_complete(dummy_unit, 1.0)) construct.elapsed_time = 2.0 self.assertTrue(construct.is_complete(dummy_unit, 1.0))
def test_is_possible_returns_false_if_unit_can_not_construct_that_building_type(self): # noqa dummy_building = MagicMock() dummy_unit = MagicMock() dummy_unit.can_construct_building.return_value = False construct = Construct(dummy_building) self.assertFalse(construct.is_possible(dummy_unit, 1.0)) dummy_unit.can_construct_building.assert_called_once_with( dummy_building ) dummy_unit.can_construct_building.return_value = True self.assertTrue(construct.is_possible(dummy_unit, 1.0))
def test_finish_constructs_the_building_and_places_it_on_the_tile_map(self): # noqa dummy_building = MagicMock() dummy_unit = MagicMock() dummy_unit.pt = 'dummy_point' dummy_unit.construct_building.return_value = dummy_building construct = Construct(dummy_building) construct.finish(dummy_unit, 1.0) dummy_unit.construct_building.assert_called_once_with(dummy_building) dummy_unit.tile_map.place_building.assert_called_once_with( dummy_building, 'dummy_point', )
def test_seconds_remaining_property_returns_the_difference_between_the_elapsed_time_and_the_build_time(self): # noqa dummy_building = MagicMock() dummy_building.build_time = 2.0 construct = Construct(dummy_building) construct.elapsed_time = 1.9 self.assertEqual(round(construct.seconds_remaining, 6), 0.1)