Exemplo n.º 1
0
def test_generate_output_in_normal():
    issues = {'has a license': (True, "LICENSE exists and isn't empty."),
              'has remotes': (False, 'There are no remotes.'),
              'has no uncommitted changes': (False, 'Run `git status` to see... '),
              'has no stash': (True, 'The git stash is empty.'),
              'has no unpushed commits': (False, 'There are ...'),
              'has a readme': (True, "README exists and isn't empty.")}

    for verbose, quiet in ((True, False), (False, False), (False, True)):
        output = generate_output(issues, verbose=verbose, quiet=quiet, directory="/foo/bar/baz")
        if quiet:
            assert not output
        else:
            for line in output:
                found_issue_in_line = False
                for issue in issues:
                    success, message = issues[issue]
                    if issue in line:
                        found_issue_in_line = True
                        if verbose:
                            assert message in line
                        else:
                            assert message not in line
                        if success:
                            assert "pass" in line.lower()
                        else:
                            assert "fail" in line.lower()
                if not found_issue_in_line:
                    assert "pass" not in line.lower()
                    assert "fail" not in line.lower()
Exemplo n.º 2
0
def test_generate_output_prints_directory_in_verbose_only():
    issues = {'has a license': (True, "LICENSE exists and isn't empty."),
              'has remotes': (False, 'There are no remotes.'),
              'has no uncommitted changes': (False, 'Run `git status` to see... '),
              'has no stash': (True, 'The git stash is empty.'),
              'has no unpushed commits': (False, 'There are ...'),
              'has a readme': (True, "README exists and isn't empty.")}

    output = generate_output(issues, verbose=True, quiet=False, directory="/foo/bar/baz")
    assert "/foo/bar/baz" in "\n".join(output)

    output = generate_output(issues, verbose=False, quiet=False, directory="/foo/bar/baz")
    assert "/foo/bar/baz" not in "\n".join(output)

    output = generate_output(issues, verbose=False, quiet=True, directory="/foo/bar/baz")
    assert "/foo/bar/baz" not in "\n".join(output)
Exemplo n.º 3
0
def test_generate_output_makes_no_output_in_quiet():
    issues = {'has a license': (True, "LICENSE exists and isn't empty."),
              'has remotes': (False, 'There are no remotes.'),
              'has no uncommitted changes': (False, 'Run `git status` to see... '),
              'has no stash': (True, 'The git stash is empty.'),
              'has no unpushed commits': (False, 'There are ...'),
              'has a readme': (True, "README exists and isn't empty.")}

    output = generate_output(issues, verbose=False, quiet=True, directory="/foo/bar/baz")
    assert not output

    issues = {'has a license': (True, "LICENSE exists and isn't empty.")}
    output = generate_output(issues, verbose=False, quiet=True, directory="/foo/bar/baz")
    assert not output

    issues = {'has a license': (False, "Where my LICENSE at?")}
    output = generate_output(issues, verbose=False, quiet=True, directory="/foo/bar/baz")
    assert not output