Ejemplo n.º 1
0
def test_show_md_with_hash(capsys):
    diff = {
        "deleted": [
            {
                "path": "zoo",
                "hash": "22222"
            },
            {
                "path": os.path.join("data", ""),
                "hash": "XXXXXXXX.dir"
            },
            {
                "path": os.path.join("data", "foo"),
                "hash": "11111111"
            },
            {
                "path": os.path.join("data", "bar"),
                "hash": "00000000"
            },
        ],
        "modified": [{
            "path": "file",
            "hash": {
                "old": "AAAAAAAA",
                "new": "BBBBBBBB"
            }
        }],
        "added": [{
            "path": "file",
            "hash": "00000000"
        }],
        "renamed": [{
            "path": {
                "old": "file_old",
                "new": "file_new"
            },
            "hash": "11111111",
        }],
        "not in cache": [{
            "path": "file2",
            "hash": "12345678"
        }],
    }

    _show_md(diff, show_hash=True)

    out, _ = capsys.readouterr()
    assert out == (
        "| Status       | Hash               | Path                 |\n"
        "|--------------|--------------------|----------------------|\n"
        "| added        | 00000000           | file                 |\n"
        "| deleted      | 22222              | zoo                  |\n"
        "| deleted      | XXXXXXXX           | data{sep}                |\n"
        "| deleted      | 11111111           | data{sep}foo             |\n"
        "| deleted      | 00000000           | data{sep}bar             |\n"
        "| renamed      | 11111111           | file_old -> file_new |\n"
        "| modified     | AAAAAAAA..BBBBBBBB | file                 |\n"
        "| not in cache | 12345678           | file2                |\n"
        "\n").format(sep=os.path.sep)
Ejemplo n.º 2
0
def test_show_md_hide_missing(capsys):
    diff = {
        "deleted": [
            {
                "path": "zoo"
            },
            {
                "path": os.path.join("data", "")
            },
            {
                "path": os.path.join("data", "foo")
            },
            {
                "path": os.path.join("data", "bar")
            },
        ],
        "modified": [{
            "path": "file"
        }],
        "added": [{
            "path": "file"
        }],
        "renamed": [{
            "path": {
                "old": "file_old",
                "new": "file_new"
            }
        }],
        "not in cache": [{
            "path": "file2"
        }],
    }

    _show_md(diff, hide_missing=True)

    out, _ = capsys.readouterr()
    assert out == ("| Status   | Path                 |\n"
                   "|----------|----------------------|\n"
                   "| added    | file                 |\n"
                   "| deleted  | zoo                  |\n"
                   "| deleted  | data{sep}                |\n"
                   "| deleted  | data{sep}foo             |\n"
                   "| deleted  | data{sep}bar             |\n"
                   "| renamed  | file_old -> file_new |\n"
                   "| modified | file                 |\n"
                   "\n").format(sep=os.path.sep)
Ejemplo n.º 3
0
def test_show_md():
    diff = {
        "deleted": [
            {
                "path": "zoo"
            },
            {
                "path": os.path.join("data", "")
            },
            {
                "path": os.path.join("data", "foo")
            },
            {
                "path": os.path.join("data", "bar")
            },
        ],
        "modified": [{
            "path": "file"
        }],
        "added": [{
            "path": "file"
        }],
        "renamed": [{
            "path": {
                "old": "file_old",
                "new": "file_new"
            }
        }],
        "not in cache": [{
            "path": "file2"
        }],
    }
    assert _show_md(diff) == (
        "| Status       | Path                 |\n"
        "|--------------|----------------------|\n"
        "| added        | file                 |\n"
        "| deleted      | zoo                  |\n"
        "| deleted      | data{sep}                |\n"
        "| deleted      | data{sep}foo             |\n"
        "| deleted      | data{sep}bar             |\n"
        "| renamed      | file_old -> file_new |\n"
        "| modified     | file                 |\n"
        "| not in cache | file2                |\n").format(sep=os.path.sep)
Ejemplo n.º 4
0
def test_show_md():
    diff = {
        "deleted": [
            {
                "path": "zoo",
                "hash": "22222"
            },
            {
                "path": os.path.join("data", ""),
                "hash": "XXXXXXXX.dir"
            },
            {
                "path": os.path.join("data", "foo"),
                "hash": "11111111"
            },
            {
                "path": os.path.join("data", "bar"),
                "hash": "00000000"
            },
        ],
        "modified": [{
            "path": "file",
            "hash": {
                "old": "AAAAAAAA",
                "new": "BBBBBBBB"
            }
        }],
        "added": [{
            "path": "file",
            "hash": "00000000"
        }],
    }
    assert _show_md(diff) == ("| Status   | Path     |\n"
                              "|----------|----------|\n"
                              "| added    | file     |\n"
                              "| deleted  | data{sep}    |\n"
                              "| deleted  | data{sep}bar |\n"
                              "| deleted  | data{sep}foo |\n"
                              "| deleted  | zoo      |\n"
                              "| modified | file     |\n").format(
                                  sep=os.path.sep)
Ejemplo n.º 5
0
def test_show_md():
    diff = {
        "deleted": [
            {"path": "zoo"},
            {"path": os.path.join("data", "")},
            {"path": os.path.join("data", "foo")},
            {"path": os.path.join("data", "bar")},
        ],
        "modified": [{"path": "file"}],
        "added": [{"path": "file"}],
    }
    assert _show_md(diff) == (
        "| Status   | Path     |\n"
        "|----------|----------|\n"
        "| added    | file     |\n"
        "| deleted  | zoo      |\n"
        "| deleted  | data{sep}    |\n"
        "| deleted  | data{sep}foo |\n"
        "| deleted  | data{sep}bar |\n"
        "| modified | file     |\n"
    ).format(sep=os.path.sep)
Ejemplo n.º 6
0
def test_show_md_empty():
    assert _show_md({}) == ("| Status   | Path   |\n|----------|--------|\n")