def test_salt_cp(master, minion, salt_cp, tempfiles):
    '\n    Test copying a file from the master to the minion\n    '
    tfile = tempfile.NamedTemporaryFile(delete=True)
    tfile.close()
    dest = tfile.name
    try:
        contents = 'id: foo'
        sls = tempfiles.makeslsfile(contents)
        assert master.is_alive()
        assert minion.is_alive()
        ret = salt_cp.run('minion-1', sls, dest)
        assert (ret.exitcode == 0), ret
        assert (ret.json == {'minion-1': {dest: True}}), ret
        assert os.path.exists(dest)
        with open(dest) as rfh:
            assert (rfh.read() == contents)
    finally:
        if os.path.exists(dest):
            os.unlink(dest)
    tfile = tempfile.NamedTemporaryFile(delete=True)
    tfile.close()
    dest = tfile.name
    try:
        contents = 'id: foo'
        sls = tempfiles.makeslsfile(contents)
        assert master.is_alive()
        assert minion.is_alive()
        ret = salt_cp.run(sls, dest, minion_tgt='minion-1')
        assert (ret.exitcode == 0), ret
        assert (ret.json == {dest: True}), ret
        assert os.path.exists(dest)
        with open(dest) as rfh:
            assert (rfh.read() == contents)
    finally:
        if os.path.exists(dest):
            os.unlink(dest)
Test copying a file from the master to the minion
def test_salt_cp(master, minion, salt_cp, tempfiles):
    '\n    \n    '
    tfile = tempfile.NamedTemporaryFile(delete=True)
    tfile.close()
    dest = tfile.name
    try:
        contents = 'id: foo'
        sls = tempfiles.makeslsfile(contents)
        assert master.is_alive()
        assert minion.is_alive()
        ret = salt_cp.run('minion-1', sls, dest)
        assert (ret.exitcode == 0), ret
        assert (ret.json == {'minion-1': {dest: True}}), ret
        assert os.path.exists(dest)
        with open(dest) as rfh:
            assert (rfh.read() == contents)
    finally:
        if os.path.exists(dest):
            os.unlink(dest)
    tfile = tempfile.NamedTemporaryFile(delete=True)
    tfile.close()
    dest = tfile.name
    try:
        contents = 'id: foo'
        sls = tempfiles.makeslsfile(contents)
        assert master.is_alive()
        assert minion.is_alive()
        ret = salt_cp.run(sls, dest, minion_tgt='minion-1')
        assert (ret.exitcode == 0), ret
        assert (ret.json == {dest: True}), ret
        assert os.path.exists(dest)
        with open(dest) as rfh:
            assert (rfh.read() == contents)
    finally:
        if os.path.exists(dest):
            os.unlink(dest)