def setup_method(self, method): self.ya = yaml_assistant.YamlAssistant('ya', {}, '') self.ya.role = 'creator' self.ya._files = { 'first': { 'source': 'f/g' }, 'second': { 'source': 's/t' } } self.tlh = TestLoggingHandler.create_fresh_handler() self.ya2 = yaml_assistant.YamlAssistant('ya2', {}, '') self.ya2._files = {} self.ya2.role = 'creator' self.ya2._run = [{ 'if $ide': [{ 'if $(test -d /notachance)': [{ 'log_d': 'ifif' }] }, { 'else': [{ 'log_d': 'ifelse' }] }] }, { 'else': [{ 'log_d': 'else' }] }]
def assistant_from_yaml(cls, source, y, superassistant, fully_loaded=True, role=settings.DEFAULT_ASSISTANT_ROLE): """Constructs instance of YamlAssistant loaded from given structure y, loaded from source file source. Args: source: path to assistant source file y: loaded yaml structure superassistant: superassistant of this assistant Returns: YamlAssistant instance constructed from y with source file source Raises: YamlError: if the assistant is malformed """ # In pre-0.9.0, we required assistant to be a mapping of {name: assistant_attributes} # now we allow that, but we also allow omitting the assistant name and putting # the attributes to top_level, too. name = os.path.splitext(os.path.basename(source))[0] yaml_checker.check(source, y) assistant = yaml_assistant.YamlAssistant(name, y, source, superassistant, fully_loaded=fully_loaded, role=role) return assistant
def test_finds_supported_icon_formats(self, a, f): ya = yaml_assistant.YamlAssistant( a, {}, os.path.join(settings.DATA_DIRECTORIES[0], 'assistants/crt/{0}.yaml').format(a), None) assert ya.icon_path == os.path.join(settings.DATA_DIRECTORIES[0], 'icons/crt', a + f) assert ya.default_icon_path == ya.icon_path
def setup_method(self, method): self.ya = yaml_assistant.YamlAssistant('ya', {}, '', None) self.ya.role = 'crt' self.ya._files = {'first': {'source': 'f/g'}, 'second': {'source': 's/t'}} self.ya._dependencies = [{'rpm': ['foo']}] self.ya._dependencies_a = [{'rpm': ['bar']}] self.ya._pre_run = [{'log_i': 'pre'}] self.ya._run = [{'log_i': 'run'}] self.ya._post_run = [{'log_i': 'post'}] self.tlh = TestLoggingHandler.create_fresh_handler()
def assistant_from_yaml(cls, source, y, fully_loaded=True, role='creator'): """Constructs instance of YamlAssistant loaded from given structure y, loaded from source file source. Args: source: path to assistant source file y: loaded yaml structure Returns: YamlAssistant instance constructed from y with source file source """ # assume only one key and value name, attrs = y.popitem() assistant = yaml_assistant.YamlAssistant(name, attrs, source, fully_loaded=fully_loaded, role=role) return assistant
def setup_method(self, method): self.ya = yaml_assistant.YamlAssistant('ya', {}, '', None) self.ya.role = 'mod' self.ya._files = {} self.tlh = TestLoggingHandler.create_fresh_handler() self.dda = {'project_type': ['foo', 'bar', 'baz']}
def setup_method(self, method): self.ya = yaml_assistant.YamlAssistant('ya', {}, '') self.ya.role = 'modifier' self.ya._files = {} self.tlh = TestLoggingHandler.create_fresh_handler() self.dda = {'subassistant_path': ['foo', 'bar', 'baz']}