def test_load_mixed_quest_definitions(self): '''Tests loading a QuestSet with quests defined as strings and as classes.''' quest_set_source = ''' from phonyep.aquest import AQuest from eosclubhouse.libquest import Registry, QuestSet class TestQuestSet(QuestSet): __pathway_name__ = 'web' __character_id__ = 'phony' __quests__ = [AQuest, 'ZQuest'] Registry.register_quest_set(TestQuestSet) ''' quest_source_template = ''' from eosclubhouse.libquest import Quest class {}(Quest): pass ''' with tempfile.TemporaryDirectory() as tmpdir: episode_name = 'phonyep' dir_name = os.path.join(tmpdir, episode_name) os.mkdir(dir_name) quest_names = ['AQuest', 'ZQuest'] for name in quest_names: with open(os.path.join(dir_name, name.lower() + '.py'), 'w') as quest_set_file: quest_set_file.write(quest_source_template.format(name)) # Set the quests for the QuestSet, the first is given as a string, the second as a # symbol. with open(os.path.join(dir_name, 'testquestset.py'), 'w') as quest_set_file: quest_set_file.write(quest_set_source) Registry._reset() Registry._loaded_episode = episode_name Registry.load(dir_name) self.assertIn('TestQuestSet', [ quest_set.get_id() for quest_set in Registry.get_quest_sets() ])
def setup_episode(quest_set_list, episode_name='tests-phony-episode'): Registry._reset() Registry._quest_sets = quest_set_list Registry._loaded_episode = episode_name