Example #1
0
def test_lint_warns_P003(*args):
    warn_lint = ['P003']
    config.set_primary_repo('../pegleg/site_yamls/')

    with mock.patch.object(lint, '_verify_no_unexpected_files') as mock_method:
        lint.full(False, [], warn_lint)
    mock_method.assert_called()
Example #2
0
def test_lint_warns_P002(*args):
    warn_lint = ['P002']
    config.set_primary_repo('../pegleg/site_yamls/')

    with mock.patch.object(lint, '_verify_deckhand_render') as mock_method:
        lint.full(False, [], warn_lint)
    mock_method.assert_called()
Example #3
0
def test_lint_excludes_P002(*args):
    exclude_lint = ['P002']
    config.set_primary_repo('../pegleg/site_yamls/')
    with mock.patch.object(lint,
                           '_verify_deckhand_render',
                           return_value=[('P002', 'test message')
                                         ]) as mock_method:
        lint.full(False, exclude_lint, [])
    mock_method.assert_called()
Example #4
0
File: cli.py Project: cb371j/pegleg
def lint(*, fail_on_missing_sub_src, primary_repo, aux_repo, exclude_lint,
         warn_lint):
    config.set_primary_repo(primary_repo)
    config.set_auxiliary_repo_list(aux_repo or [])
    warns = engine.lint.full(fail_on_missing_sub_src, exclude_lint, warn_lint)
    if warns:
        click.echo("Linting passed, but produced some warnings.")
        for w in warns:
            click.echo(w)
Example #5
0
def test_no_non_yamls(tmpdir):
    p = tmpdir.mkdir("site_yamls").mkdir("global")
    for x in range(3):  # Create 3 YAML files
        p.join("good-%d.yaml" % x).write('fake-content')
    p.join("bad.txt").write("fake-content")
    config.set_primary_repo(str(tmpdir.listdir()[0]))
    results = list(files.all())

    assert 3 == len(results)
    # Make sure only YAML files are returned
    for i in results:
        assert i.endswith('.yaml')
Example #6
0
def test_lint_warns_P001(*args):
    warn_lint = ['P001']
    config.set_primary_repo('../pegleg/site_yamls/')

    code_1 = 'X001'
    msg_1 = 'is a secret, but has unexpected storagePolicy: "cleartext"'
    code_2 = 'X002'
    msg_2 = 'test msg'
    msgs = [(code_1, msg_1), (code_2, msg_2)]

    with mock.patch.object(lint, '_verify_file_contents',
                           return_value=msgs) as mock_methed:
        with pytest.raises(click.ClickException) as expected_exc:
            lint.full(False, [], warn_lint)
            assert msg_1 not in expected_exc
            assert msg_2 in expected_exc
Example #7
0
File: cli.py Project: cb371j/pegleg
def site(primary_repo, aux_repo):
    config.set_primary_repo(primary_repo)
    config.set_auxiliary_repo_list(aux_repo or [])