def setup(self):
        """
        Setup test case
        """
        self.creature_config = CreatureConfigurations(Random())

        self.model = mock()
        self.action_factory = mock()
        self.rng = Random()

        self.creature_config.add_creature(
                        CreatureConfiguration(name = 'rat',
                                              body = 4,
                                              finesse = 12,
                                              mind = 2,
                                              hp = 2,
                                              speed = 2,
                                              icons = [100, 101],
                                              attack = 2,
                                              ai = FlockingHerbivore))

        self.creature_config.add_creature(
                        CreatureConfiguration(name = 'spider',
                                              body = 6,
                                              finesse = 12,
                                              mind = 8,
                                              hp = 6,
                                              speed = 1,
                                              icons = [102],
                                              attack = 4,
                                              ai = FlockingHerbivore,
                                              effect_handles = [EffectHandle(
                                                    trigger = 'on attack hit',
                                                    effect = 'minor poison',
                                                    parameters = None,
                                                    charges = 100)]))

        self.generator = CreatureGenerator(configuration = self.creature_config,
                                           model = self.model,
                                           action_factory = self.action_factory,
                                           rng = self.rng
                                           )
class TestCreatureGeneration(object):
    """
    Tests for creature generator
    """
    def __init__(self):
        """
        Default constructor
        """
        super(TestCreatureGeneration, self).__init__()
        self.creature_config = None
        self.generator = None

        self.model = None
        self.action_factory = None
        self.rng = None

    def setup(self):
        """
        Setup test case
        """
        self.creature_config = CreatureConfigurations(Random())

        self.model = mock()
        self.action_factory = mock()
        self.rng = Random()

        self.creature_config.add_creature(
                        CreatureConfiguration(name = 'rat',
                                              body = 4,
                                              finesse = 12,
                                              mind = 2,
                                              hp = 2,
                                              speed = 2,
                                              icons = [100, 101],
                                              attack = 2,
                                              ai = FlockingHerbivore))

        self.creature_config.add_creature(
                        CreatureConfiguration(name = 'spider',
                                              body = 6,
                                              finesse = 12,
                                              mind = 8,
                                              hp = 6,
                                              speed = 1,
                                              icons = [102],
                                              attack = 4,
                                              ai = FlockingHerbivore,
                                              effect_handles = [EffectHandle(
                                                    trigger = 'on attack hit',
                                                    effect = 'minor poison',
                                                    parameters = None,
                                                    charges = 100)]))

        self.generator = CreatureGenerator(configuration = self.creature_config,
                                           model = self.model,
                                           action_factory = self.action_factory,
                                           rng = self.rng
                                           )

    def test_creating_simple_creature(self):
        """
        Test that simple creature can be created by name
        """
        creature = self.generator.generate_creature(name = 'rat')

        assert_that(creature.name, is_(equal_to('rat')))

    def test_creating_creature_with_effect(self):
        """
        Test that creature with effect can be created
        """
        creature = self.generator.generate_creature(name = 'spider')

        assert_that(creature, has_effect_handle())

    def test_creating_creature_with_ai(self):
        """
        Test that creature can have AI created
        """
        creature = self.generator.generate_creature(name = 'rat')

        assert_that(creature.artificial_intelligence,
                    is_(not_none()))