File: bw_diff.py

package info (click to toggle)
bundlewrap 4.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,216 kB
  • sloc: python: 20,299; makefile: 2
file content (95 lines) | stat: -rw-r--r-- 2,543 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from bundlewrap.utils.testing import make_repo, run


def test_metadata(tmpdir):
    make_repo(
        tmpdir,
        nodes={
            "node1": {'metadata': {"key": "value1"}},
            "node2": {'metadata': {"key": "value2"}},
        },
    )
    stdout, stderr, rcode = run("bw diff -m node1 node2", path=str(tmpdir))
    assert b"value1" in stdout
    assert b"value2" in stdout
    assert stderr == b""
    assert rcode == 0


def test_file_items(tmpdir):
    make_repo(
        tmpdir,
        nodes={
            "node1": {'bundles': ["bundle1"]},
            "node2": {'bundles': ["bundle2"]},
        },
        bundles={
            "bundle1": {
                'items': {
                    "files": {
                        "/tmp/test": {
                            'content': "one",
                        },
                    },
                },
            },
            "bundle2": {
                'items': {
                    "files": {
                        "/tmp/test": {
                            'content': "two",
                        },
                    },
                },
            },
        },
    )
    stdout, stderr, rcode = run("bw diff -i file:/tmp/test -- node1 node2", path=str(tmpdir))
    assert b"one" in stdout
    assert b"two" in stdout
    assert stderr == b""
    assert rcode == 0


def test_whole_node(tmpdir):
    make_repo(
        tmpdir,
        nodes={
            "node1": {'bundles': ["bundle1", "bundle3"]},
            "node2": {'bundles': ["bundle2", "bundle3"]},
        },
        bundles={
            "bundle1": {
                'items': {
                    "files": {
                        "/tmp/foo": {
                            'content': "one",
                        },
                    },
                },
            },
            "bundle2": {
                'items': {
                    "files": {
                        "/tmp/foo": {
                            'content': "two",
                        },
                    },
                },
            },
            "bundle3": {
                'items': {
                    "files": {
                        "/tmp/bar": {
                            'content': "common",
                        },
                    },
                },
            },
        },
    )
    stdout, stderr, rcode = run("bw diff node1 node2", path=str(tmpdir))
    assert b"/tmp/foo" in stdout
    assert b"/tmp/bar" not in stdout
    assert stderr == b""
    assert rcode == 0