How to use the bundlewrap.utils.testing.host_os function in bundlewrap

To help you get started, we’ve selected a few bundlewrap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bundlewrap / bundlewrap / tests / integration / bw_apply_symlinks.py View on Github external
mkdir(join(str(tmpdir), "foo"))
    make_repo(
        tmpdir,
        bundles={
            "test": {
                'symlinks': {
                    join(str(tmpdir), "foo"): {
                        'target': "/dev/null",
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )
    stdout, stderr, rcode = run("bw apply localhost", path=str(tmpdir))
    assert rcode == 0
    assert readlink(join(str(tmpdir), "foo")) == "/dev/null"
github bundlewrap / bundlewrap / tests / integration / bw_apply_git_deploy.py View on Github external
join(str(tmpdir), "git_deployed_bw"): {
                        'repo': "https://github.com/bundlewrap/bundlewrap.git",
                        'rev': "master",
                    },
                },
                'directories': {
                    join(str(tmpdir), "git_deployed_bw"): {
                        'purge': True,
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )

    stdout, stderr, rcode = run("bw apply localhost", path=str(tmpdir))
    assert rcode == 1
    assert b"cannot git_deploy into purged directory" in stderr
github bundlewrap / bundlewrap / tests / integration / bw_lock.py View on Github external
def test_add_lock_apply_remove(tmpdir):
    make_repo(
        tmpdir,
        nodes={
            "localhost": {
                'bundles': ["bundle1"],
                'os': host_os(),
            },
        },
        bundles={
            "bundle1": {
                'files': {
                    "/tmp/bw_test_lock_add": {
                        'content': "foo",
                    },
                },
            },
        },
    )
    run("rm -f /tmp/bw_test_lock_add")
    stdout, stderr, rcode = run("BW_IDENTITY=jdoe bw lock add -c höhöhö -e 1m -i file:/tmp/bw_test_lock_add localhost", path=str(tmpdir))
    assert rcode == 0
    lock_id = get_lock_id(stdout.decode('utf-8'))
github bundlewrap / bundlewrap / tests / integration / bw_apply_autoskip.py View on Github external
def test_skip_bundle(tmpdir):
    make_repo(
        tmpdir,
        bundles={
            "test": {
                'files': {
                    join(str(tmpdir), "foo"): {
                        'content': "nope",
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )
    result = run("bw apply --skip bundle:test localhost", path=str(tmpdir))
    assert result[2] == 0
    assert not exists(join(str(tmpdir), "foo"))
github bundlewrap / bundlewrap / tests / integration / bw_apply_precedes.py View on Github external
'tags': ["tag1"],
                        'unless': 'true',
                    },
                    "action3": {
                        'command': "echo 3 >> {}".format(join(str(tmpdir), "file")),
                        'tags': ["tag1"],
                        'needs': ["action:action2"],
                        'unless': 'true',
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )
    run("bw apply localhost", path=str(tmpdir))
    assert not exists(join(str(tmpdir), "file"))
github bundlewrap / bundlewrap / tests / integration / bw_apply_secrets.py View on Github external
def test_fault_content(tmpdir):
    make_repo(
        tmpdir,
        bundles={
            "test": {},
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )

    with open(join(str(tmpdir), "bundles", "test", "items.py"), 'w') as f:
        f.write("""
files = {{
    "{}": {{
        'content': repo.vault.password_for("test"),
    }},
}}
""".format(join(str(tmpdir), "secret")))

    run("bw apply localhost", path=str(tmpdir))
    with open(join(str(tmpdir), "secret")) as f:
        content = f.read()
github bundlewrap / bundlewrap / tests / integration / bw_apply_files.py View on Github external
def test_binary_template_content(tmpdir):
    make_repo(
        tmpdir,
        bundles={
            "test": {
                'files': {
                    join(str(tmpdir), "foo.bin"): {
                        'encoding': 'latin-1',
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )
    with open(join(str(tmpdir), "bundles", "test", "files", "foo.bin"), 'wb') as f:
        f.write("ö".encode('utf-8'))

    run("bw apply localhost", path=str(tmpdir))
    with open(join(str(tmpdir), "foo.bin"), 'rb') as f:
        content = f.read()
    assert content.decode('latin-1') == "ö"
github bundlewrap / bundlewrap / tests / integration / bw_apply_directories.py View on Github external
},
                    join(str(tmpdir), "purgedir", "subdir1", "managed_file"): {
                        'content': "content",
                    },
                },
                'directories': {
                    join(str(tmpdir), "purgedir"): {
                        'purge': True,
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )

    mkdir(join(str(tmpdir), "purgedir"))
    mkdir(join(str(tmpdir), "purgedir", "subdir2"))
    mkdir(join(str(tmpdir), "purgedir", "subdir3"))

    with open(join(str(tmpdir), "purgedir", "unmanaged_file"), 'w') as f:
        f.write("content")
    with open(join(str(tmpdir), "purgedir", "subdir3", "unmanaged_file"), 'w') as f:
        f.write("content")

    run("bw apply localhost", path=str(tmpdir))

    assert not exists(join(str(tmpdir), "purgedir", "unmanaged_file"))
github bundlewrap / bundlewrap / tests / integration / bw_apply_git_deploy.py View on Github external
"test": {
                'git_deploy': {
                    join(str(tmpdir), "git_deployed_bw"): {
                        'repo': "https://github.com/bundlewrap/bundlewrap.git",
                        'rev': "master",
                    },
                },
                'directories': {
                    join(str(tmpdir), "git_deployed_bw"): {},
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )

    assert not exists(join(str(tmpdir), "git_deployed_bw", "LICENSE"))
    stdout, stderr, rcode = run("bw apply localhost", path=str(tmpdir))
    assert rcode == 0
    assert exists(join(str(tmpdir), "git_deployed_bw", "LICENSE"))
    assert not exists(join(str(tmpdir), "git_deployed_bw", ".git"))
github bundlewrap / bundlewrap / tests / integration / bw_apply_precedes.py View on Github external
"action2": {
                        'command': "echo 2 >> {}".format(join(str(tmpdir), "file")),
                        'tags': ["tag1"],
                    },
                    "action3": {
                        'command': "echo 3 >> {}".format(join(str(tmpdir), "file")),
                        'tags': ["tag1"],
                        'needs': ["action:action2"],
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )
    run("bw apply localhost", path=str(tmpdir))
    with open(join(str(tmpdir), "file")) as f:
        content = f.read()
    assert content == "1\n2\n3\n"