示例#1
0
def test_remove_submodule():
    ret = get_file_diff_stats_from_output(REMOVE_SUBMODULE_COMMIT)
    assert ret == [
        FileDiffStat(
            b'.gitmodules',
            [],
            [
                b'[submodule "verifycppbraces"]',
                b'       path = verifycppbraces',
                b'       url = git://github.com/asottile/verifycppbraces.git',
            ],
            Status.ALREADY_EXISTING,
        ),
        FileDiffStat(
            b'verifycppbraces',
            [],
            [],
            Status.DELETED,
            special_file=SpecialFile(
                file_type=SpecialFileType.SUBMODULE,
                added=None,
                removed=b'72053d85133aa854e2762a4b604976da825750fb',
            ),
        ),
    ]
def test_submodule_count_detects_ignores_moved():
    parser = SubmoduleCount()
    input_stats = (
        FileDiffStat(
            b'foo', [], [], Status.ALREADY_EXISTING,
            special_file=SpecialFile(SpecialFileType.SUBMODULE, b'br', b'bz'),
        ),
    )

    assert not tuple(parser.get_metrics_from_stat(BLANK_COMMIT, input_stats))
def test_binary_file_count_detects_ignores_moved():
    parser = BinaryFileCount()
    input_stats = [
        FileDiffStat(
            'foo', [], [], Status.ALREADY_EXISTING,
            special_file=SpecialFile(SpecialFileType.BINARY, 'foo', 'foo'),
        ),
    ]

    assert not tuple(parser.get_metrics_from_stat(Commit.blank, input_stats))
def test_binary_file_count_detects_deleted():
    parser = BinaryFileCount()
    input_stats = [
        FileDiffStat(
            'foo', [], [], Status.DELETED,
            special_file=SpecialFile(SpecialFileType.BINARY, None, 'foo'),
        ),
    ]

    metric, = parser.get_metrics_from_stat(Commit.blank, input_stats)
    assert metric == Metric('BinaryFileCount', -1)
示例#5
0
def test_binary_file_count_detects_ignores_moved():
    parser = BinaryFileCount()
    input_stats = (FileDiffStat(
        b'foo',
        [],
        [],
        Status.ALREADY_EXISTING,
        special_file=SpecialFile(SpecialFileType.BINARY, b'foo', b'foo'),
    ), )

    assert not tuple(parser.get_metrics_from_stat(BLANK_COMMIT, input_stats))
def test_submodule_count_detects_added():
    parser = SubmoduleCount()
    input_stats = (
        FileDiffStat(
            b'foo', [], [], Status.ADDED,
            special_file=SpecialFile(SpecialFileType.SUBMODULE, b'bar', None),
        ),
    )

    metric, = parser.get_metrics_from_stat(BLANK_COMMIT, input_stats)
    assert metric == Metric('SubmoduleCount', 1)
def test_bump_submodule():
    ret = get_file_diff_stats_from_output(BUMP_SUBMODULE_COMMIT)
    assert ret == [
        FileDiffStat(
            b'verifycppbraces', [], [], Status.ALREADY_EXISTING,
            special_file=SpecialFile(
                file_type=SpecialFileType.SUBMODULE,
                added=b'd7c12e294428b60667dedd46ed7f00c04e36b7e4',
                removed=b'72053d85133aa854e2762a4b604976da825750fb',
            ),
        ),
    ]
示例#8
0
def test_binary_file_count_detects_added():
    parser = BinaryFileCount()
    input_stats = (FileDiffStat(
        b'foo',
        [],
        [],
        Status.ADDED,
        special_file=SpecialFile(SpecialFileType.BINARY, b'foo', None),
    ), )

    metric, = parser.get_metrics_from_stat(BLANK_COMMIT, input_stats)
    assert metric == Metric('BinaryFileCount', 1)
def test_modified_binary_commit():
    ret = get_file_diff_stats_from_output(MODIFY_BINARY_COMMIT)
    assert ret == [
        FileDiffStat(
            b'foo.pdf', [], [], Status.ALREADY_EXISTING,
            special_file=SpecialFile(
                file_type=SpecialFileType.BINARY,
                added=b'foo.pdf',
                removed=b'foo.pdf',
            ),
        ),
    ]
def test_remove_binary_commit():
    ret = get_file_diff_stats_from_output(REMOVE_BINARY_COMMIT)
    assert ret == [
        FileDiffStat(
            b'foo.pdf', [], [], Status.DELETED,
            special_file=SpecialFile(
                file_type=SpecialFileType.BINARY,
                added=None,
                removed=b'foo.pdf',
            ),
        ),
    ]
示例#11
0
def test_symlink_count_detects_ignores_moved():
    parser = SymlinkCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.ALREADY_EXISTING,
            special_file=SpecialFile(SpecialFileType.SYMLINK, 'bar', 'baz'),
        ),
    ]

    assert not tuple(parser.get_metrics_from_stat(Commit.blank, input_stats))
def test_moving_symlink():
    ret = get_file_diff_stats_from_output(COMMIT_MOVING_SYMLINK)
    assert ret == [
        FileDiffStat(
            b'pa2',
            [], [],
            Status.ALREADY_EXISTING,
            special_file=SpecialFile(
                file_type=SpecialFileType.SYMLINK,
                added=b'apache/',
                removed=b'apache/html1/2mJe7Zhz/pa2/',
            ),
        ),
    ]
示例#13
0
def test_symlink_count_detects_ignores_moved():
    parser = SymlinkCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.ALREADY_EXISTING,
            special_file=SpecialFile(SpecialFileType.SYMLINK, 'bar', 'baz'),
        ),
    ]

    metrics = list(parser.get_metrics_from_stat(input_stats))
    assert metrics == [Metric('SymlinkCount', 0)]
示例#14
0
def test_symlink_count_detects_deleted():
    parser = SymlinkCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.DELETED,
            special_file=SpecialFile(SpecialFileType.SYMLINK, None, 'bar'),
        ),
    ]

    metrics = list(parser.get_metrics_from_stat(input_stats))
    assert metrics == [Metric('SymlinkCount', -1)]
示例#15
0
def test_submodule_count_detects_added():
    parser = SubmoduleCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.ADDED,
            special_file=SpecialFile(SpecialFileType.SUBMODULE, 'bar', None),
        ),
    ]

    metrics = list(parser.get_metrics_from_stat(Commit.blank, input_stats))
    assert metrics == [Metric('SubmoduleCount', 1)]
示例#16
0
def test_submodule_count_detects_ignores_moved():
    parser = SubmoduleCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.ALREADY_EXISTING,
            special_file=SpecialFile(SpecialFileType.SUBMODULE, 'bar', 'baz'),
        ),
    ]

    metrics = list(parser.get_metrics_from_stat(Commit.blank, input_stats))
    assert metrics == [Metric('SubmoduleCount', 0)]
def test_adding_symlink():
    ret = get_file_diff_stats_from_output(COMMIT_ADDING_SYMLINK)
    assert ret == [
        FileDiffStat(
            b'pa2',
            [], [],
            Status.ADDED,
            special_file=SpecialFile(
                file_type=SpecialFileType.SYMLINK,
                added=b'apache/html1/2mJe7Zhz/pa2/',
                removed=None,
            ),
        ),
    ]
示例#18
0
def test_submodule_count_detects_deleted():
    parser = SubmoduleCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.DELETED,
            special_file=SpecialFile(SpecialFileType.SUBMODULE, None, 'bar'),
        ),
    ]

    metrics = list(parser.get_metrics_from_stat(input_stats))
    assert metrics == [Metric('SubmoduleCount', -1)]
示例#19
0
def test_binary_file_count_detects_added():
    parser = BinaryFileCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.ADDED,
            special_file=SpecialFile(SpecialFileType.BINARY, 'foo', None),
        ),
    ]

    metrics = list(parser.get_metrics_from_stat(Commit.blank, input_stats))
    assert metrics == [Metric('BinaryFileCount', 1)]
示例#20
0
def test_symlink_count_detects_added():
    parser = SymlinkCount()
    input_stats = [
        FileDiffStat(
            'foo',
            [],
            [],
            Status.ADDED,
            special_file=SpecialFile(SpecialFileType.SYMLINK, 'bar', None),
        ),
    ]

    metric, = parser.get_metrics_from_stat(Commit.blank, input_stats)
    assert metric == Metric('SymlinkCount', 1)
def test_binary_files():
    ret = get_file_diff_stats_from_output(COMMIT_ENDING_WITH_BINARY_FILES)
    assert ret == [
        FileDiffStat(
            b'htdocs/css/base.css',
            [b'foo'], [],
            Status.ALREADY_EXISTING,
        ),
        FileDiffStat(
            b'htdocs/i/p.gif',
            [], [],
            Status.ADDED,
            special_file=SpecialFile(
                file_type=SpecialFileType.BINARY,
                added=b'htdocs/i/p.gif',
                removed=None,
            ),
        ),
    ]