예제 #1
0
    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)
예제 #2
0
 def from_string(cls, qname):
     group, name = split_name(qname.strip())
     return QualifierName(group, name)
예제 #3
0
 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))
예제 #4
0
def test_split_name_throws_when_invalid_format():
    with pytest.raises(RestrekError):
        utils.split_name('foo.bar.foo')
예제 #5
0
def test_split_name_throws_when_none():
    with pytest.raises(RestrekError):
        utils.split_name(None)
예제 #6
0
def test_split_name_nogroup():
    g, n = utils.split_name('bar')
    assert g is None
    assert 'bar' == n
예제 #7
0
def test_split_name():
    g, n = utils.split_name('foo.bar')
    assert 'foo' == g
    assert 'bar' == n