예제 #1
0
def test_file_render(tmpdir):
    p = tmpdir.join('tifa.yaml')
    file = File(name='tifa.yaml',
                origin='tifa.example.yaml',
                params=dict(name='tifa'))
    file.render(tmpdir.strpath)
    normalize_config(p.strpath)
예제 #2
0
파일: cli.py 프로젝트: codeKrowe/tifa
def gen(config):
    config_path = config or './tifa.yaml'
    try:
        config = normalize_config(config_path)
    except ValidationError as e:
        Prompt.warn(str(e))
        return

    if os.path.isdir(config['name']):
        Prompt.warn('ops, folder {} has been used'.format(config['name']))
        return

    template = Template(config)
    template.render('./')

    os.remove(config_path)

    Prompt.success('🎉 {} created, enjoy coding!'.format(config['name']))
예제 #3
0
def test_bad_model_in_config(tmpdir):
    p = tmpdir.join('tifa.yaml')
    p.write(mock_bad_models_config())
    with pytest.raises(ValidationError, match=r'^invalid model: .*'):
        normalize_config(p.strpath)
예제 #4
0
def test_bad_name_in_config(tmpdir):
    p = tmpdir.join('tifa.yaml')
    p.write(mock_bad_name_config())
    with pytest.raises(ValidationError,
                       match=r'^space in project name is invalid$'):
        normalize_config(p.strpath)
예제 #5
0
def test_bad_yaml(tmpdir):
    # http://pyyaml.org/wiki/PyYAMLDocumentation#YAMLError
    p = tmpdir.join('tifa.yaml')
    p.write('unbalanced blackets: ][')
    with pytest.raises(ValidationError, match=r'^invalid yaml file$'):
        normalize_config(p.strpath)
예제 #6
0
def test_no_config():
    with pytest.raises(ValidationError,
                       match=r'^no configuration file found$'):
        normalize_config('./nowhere.yaml')
예제 #7
0
def test_valid_config(tmpdir):
    p = tmpdir.join('tifa.yaml')
    p.write(mock_valid_config())
    normalize_config(p.strpath)
    assert 1