Exemple #1
0
def test_find_file(hgfs_setup_and_teardown):
    with patch.dict(
            hgfs.__opts__,
        {
            "hgfs_remotes": [{
                str(hgfs_setup_and_teardown): [{
                    "base": "default"
                }]
            }],
        },
    ):
        hgfs.init()
        hgfs.update()
        file = hgfs.find_file(path="test.sls", tgt_env="base")
        assert file[
            "path"] == hgfs.__opts__["cachedir"] + "/hgfs/refs/base/test.sls"
        assert file["rel"] == "test.sls"
        assert isinstance(file["stat"], list)
        for i in file["stat"]:
            assert isinstance(i, int)
Exemple #2
0
def test_serve_file(hgfs_setup_and_teardown):
    with patch.dict(
            hgfs.__opts__,
        {
            "hgfs_remotes": [{
                str(hgfs_setup_and_teardown): [{
                    "base": "default"
                }]
            }],
        },
    ):
        hgfs.init()
        hgfs.update()
        file = hgfs.find_file(path="test.sls", tgt_env="base")
        load = {"saltenv": "base", "loc": 0, "path": "test.sls"}
        data = hgfs.serve_file(load, file)
        assert data == {
            "data":
            "always-passes:\n  test.succeed_without_changes:\n    - name: foo\n",
            "dest": "test.sls",
        }
Exemple #3
0
def test_file_hash(hgfs_setup_and_teardown):
    with patch.dict(
            hgfs.__opts__,
        {
            "hgfs_remotes": [{
                str(hgfs_setup_and_teardown): [{
                    "base": "default"
                }]
            }],
        },
    ):
        hgfs.init()
        hgfs.update()
        file = hgfs.find_file(path="test.sls", tgt_env="base")
        load = {"saltenv": "base", "loc": 0, "path": "test.sls"}
        data = hgfs.file_hash(load, file)
        assert data == {
            "hash_type":
            "sha256",
            "hsum":
            "a6a48d90dce9c9b580efb2ed308af100a8328913dcf9441705125866551c7d8d",
        }