def test_handling_no_matches(self): """ Test that portal adder factory graciously returns empty list when no match has been found """ portal_config = [PortalAdderConfiguration(icons = (1, 2), level_type = 'catacombs', location_type = 'room', chance = 100, new_level = 'upper crypt', unique = False), PortalAdderConfiguration(icons = (1, 2), level_type = 'upper crypt', location_type = 'room', chance = 100, new_level = 'lower crypt', unique = False) ] factory = PortalAdderFactory(portal_config, self.rng) portal_adders = factory.create_portal_adders('castle') assert_that(portal_adders, has_length(0))
def test_removing_unique_portal_adders(self): """ Test that unique portal adder specificatin is removed from configuration after it has been used first time """ portal_config = [PortalAdderConfiguration(icons = (1, 2), level_type = 'catacombs', location_type = 'room', chance = 100, new_level = 'upper crypt', unique = True), PortalAdderConfiguration(icons = (1, 2), level_type = 'upper crypt', location_type = 'room', chance = 100, new_level = 'lower crypt', unique = False) ] factory = PortalAdderFactory(portal_config, self.rng) factory.level_generator_factory = mock() portal_adders = factory.create_portal_adders('catacombs') assert_that(factory.config, has_length(1))
def test_level_type_is_respected(self): """ Test that portal adder factory respects level type """ portal_config = [PortalAdderConfiguration(icons = (1, 2), level_type = 'catacombs', location_type = 'room', chance = 100, new_level = 'upper crypt', unique = False), PortalAdderConfiguration(icons = (1, 2), level_type = 'upper crypt', location_type = 'room', chance = 100, new_level = 'lower crypt', unique = False) ] factory = PortalAdderFactory(portal_config, self.rng) factory.level_generator_factory = mock() portal_adders = factory.create_portal_adders('catacombs') assert_that(portal_adders, has_length(1))
def test_removing_unique_portal_adders(self): """ Test that unique portal adder specificatin is removed from configuration after it has been used first time """ portal_config = [ PortalAdderConfiguration(icons=(1, 2), level_type='catacombs', location_type='room', chance=100, new_level='upper crypt', unique=True), PortalAdderConfiguration(icons=(1, 2), level_type='upper crypt', location_type='room', chance=100, new_level='lower crypt', unique=False) ] factory = PortalAdderFactory(portal_config, self.rng) factory.level_generator_factory = mock() portal_adders = factory.create_portal_adders('catacombs') assert_that(factory.config, has_length(1))
def test_handling_no_matches(self): """ Test that portal adder factory graciously returns empty list when no match has been found """ portal_config = [ PortalAdderConfiguration(icons=(1, 2), level_type='catacombs', location_type='room', chance=100, new_level='upper crypt', unique=False), PortalAdderConfiguration(icons=(1, 2), level_type='upper crypt', location_type='room', chance=100, new_level='lower crypt', unique=False) ] factory = PortalAdderFactory(portal_config, self.rng) portal_adders = factory.create_portal_adders('castle') assert_that(portal_adders, has_length(0))
def test_level_type_is_respected(self): """ Test that portal adder factory respects level type """ portal_config = [ PortalAdderConfiguration(icons=(1, 2), level_type='catacombs', location_type='room', chance=100, new_level='upper crypt', unique=False), PortalAdderConfiguration(icons=(1, 2), level_type='upper crypt', location_type='room', chance=100, new_level='lower crypt', unique=False) ] factory = PortalAdderFactory(portal_config, self.rng) factory.level_generator_factory = mock() portal_adders = factory.create_portal_adders('catacombs') assert_that(portal_adders, has_length(1))
def test_level_generator_is_created(self): """ Test that portal adder has level generator set to it """ portal_config = [PortalAdderConfiguration(icons = (1, 2), level_type = 'catacombs', location_type = 'room', chance = 100, new_level = 'upper crypt', unique = False)] factory = PortalAdderFactory(portal_config, self.rng) portal_adders = factory.create_portal_adders('catacombs') portal_adder = portal_adders[0] assert_that(portal_adder.level_generator_name, is_(equal_to('upper crypt')))
def test_level_generator_is_created(self): """ Test that portal adder has level generator set to it """ portal_config = [ PortalAdderConfiguration(icons=(1, 2), level_type='catacombs', location_type='room', chance=100, new_level='upper crypt', unique=False) ] factory = PortalAdderFactory(portal_config, self.rng) portal_adders = factory.create_portal_adders('catacombs') portal_adder = portal_adders[0] assert_that(portal_adder.level_generator_name, is_(equal_to('upper crypt')))