def load_plan(self, name): g, f = utils.split_name(name) path = '' for ext in C.YAML_EXTS: test_path = join(self.plans_dir, g, f + ext) if exists(test_path): path = test_path break if not exists(path): raise RestrekError('Plan %s does not exist (%s)' % (name, path)) return yaml_load_file(path)
def from_string(cls, qname): group, name = split_name(qname.strip()) return QualifierName(group, name)
def get_source(self, environment, template): g, f = utils.split_name(template) if not g: raise TemplateNotFound("no groups provided for %s" % template) return self._do_get_source(environment, join(g, f))
def test_split_name_throws_when_invalid_format(): with pytest.raises(RestrekError): utils.split_name('foo.bar.foo')
def test_split_name_throws_when_none(): with pytest.raises(RestrekError): utils.split_name(None)
def test_split_name_nogroup(): g, n = utils.split_name('bar') assert g is None assert 'bar' == n
def test_split_name(): g, n = utils.split_name('foo.bar') assert 'foo' == g assert 'bar' == n