def test_overlay(mocker, temp_dir): name = 'lorin.openstack-ansible-modules' repo = 'https://github.com/lorin/openstack-ansible-modules.git' branch = 'master' clone_dir = os.path.join(temp_dir.strpath, name) dst_dir = os.path.join(temp_dir.strpath, 'dst', '') os.mkdir(clone_dir) os.mkdir(dst_dir) # yapf: disable files = [ mocker.Mock(src=os.path.join(clone_dir, '*_manage'), dst=dst_dir), mocker.Mock(src=os.path.join(clone_dir, 'nova_quota'), dst=dst_dir), mocker.Mock(src=os.path.join(clone_dir, 'neutron_router'), dst=os.path.join(dst_dir, 'neutron_router.py')), mocker.Mock( src=os.path.join(clone_dir, 'tests'), dst=os.path.join(dst_dir, 'tests')) ] # yapf: enable git.clone(name, repo, clone_dir) git.overlay(clone_dir, files, branch) assert 5 == len(glob.glob('{}/*_manage'.format(dst_dir))) assert 1 == len(glob.glob('{}/nova_quota'.format(dst_dir))) assert 1 == len(glob.glob('{}/neutron_router.py'.format(dst_dir))) assert 2 == len(glob.glob('{}/*'.format(os.path.join(dst_dir, 'tests'))))
def test_overlay(mocker, temp_dir): name = "lorin.openstack-ansible-modules" repo = "https://github.com/lorin/openstack-ansible-modules.git" branch = "master" clone_dir = os.path.join(temp_dir.strpath, name) dst_dir = os.path.join(temp_dir.strpath, "dst", "") os.mkdir(clone_dir) os.mkdir(dst_dir) files = [ mocker.Mock(src=os.path.join(clone_dir, "*_manage"), dst=dst_dir), mocker.Mock(src=os.path.join(clone_dir, "nova_quota"), dst=dst_dir), mocker.Mock( src=os.path.join(clone_dir, "neutron_router"), dst=os.path.join(dst_dir, "neutron_router.py"), ), mocker.Mock( src=os.path.join(clone_dir, "tests"), dst=os.path.join(dst_dir, "tests"), ), ] git.clone(name, repo, clone_dir) git.overlay(clone_dir, files, branch) assert 5 == len(glob.glob("{}/*_manage".format(dst_dir))) assert 1 == len(glob.glob("{}/nova_quota".format(dst_dir))) assert 1 == len(glob.glob("{}/neutron_router.py".format(dst_dir))) assert 2 == len(glob.glob("{}/*".format(os.path.join(dst_dir, "tests"))))
def overlay(ctx): # pragma: no cover """Install gilt dependencies """ args = ctx.obj.get("args") filename = args.get("config") debug = args.get("debug") _setup(filename) for c in config.config(filename): with fasteners.InterProcessLock(c.lock_file): util.print_info("{}:".format(c.name)) if not os.path.exists(c.src): git.clone(c.name, c.git, c.src, debug=debug) if c.dst: git.extract(c.src, c.dst, c.version, debug=debug) post_commands = {c.dst: c.post_commands} else: git.overlay(c.src, c.files, c.version, debug=debug) post_commands = { conf.dst: conf.post_commands for conf in c.files } # Run post commands if any. for dst, commands in post_commands.items(): for command in commands: msg = " - running `{}` in {}".format(command, dst) util.print_info(msg) cmd = util.build_sh_cmd(command, cwd=dst) util.run_command(cmd, debug=debug)
def overlay(ctx): # pragma: no cover """ Install gilt dependencies """ args = ctx.obj.get('args') filename = args.get('config') debug = args.get('debug') _setup(filename) for c in config.config(filename): with fasteners.InterProcessLock(c.lock_file): util.print_info('{}:'.format(c.name)) if not os.path.exists(c.src): git.clone(c.name, c.git, c.src, debug=debug) if c.dst: git.extract(c.src, c.dst, c.version, debug=debug) else: git.overlay(c.src, c.files, c.version, debug=debug)
def test_overlay_existing_directory(mocker, temp_dir): name = 'lorin.openstack-ansible-modules' repo = 'https://github.com/lorin/openstack-ansible-modules.git' branch = 'master' clone_dir = os.path.join(temp_dir.strpath, name) dst_dir = os.path.join(temp_dir.strpath, 'dst', '') os.mkdir(clone_dir) os.mkdir(dst_dir) os.mkdir(os.path.join(dst_dir, 'tests')) files = [ mocker.Mock(src=os.path.join(clone_dir, 'tests'), dst=os.path.join(dst_dir, 'tests')) ] git.clone(name, repo, clone_dir) git.overlay(clone_dir, files, branch) assert 2 == len(glob.glob('{}/*'.format(os.path.join(dst_dir, 'tests'))))
def test_overlay_existing_directory(mocker, temp_dir): name = "lorin.openstack-ansible-modules" repo = "https://github.com/lorin/openstack-ansible-modules.git" branch = "master" clone_dir = os.path.join(temp_dir.strpath, name) dst_dir = os.path.join(temp_dir.strpath, "dst", "") os.mkdir(clone_dir) os.mkdir(dst_dir) os.mkdir(os.path.join(dst_dir, "tests")) files = [ mocker.Mock( src=os.path.join(clone_dir, "tests"), dst=os.path.join(dst_dir, "tests"), ) ] git.clone(name, repo, clone_dir) git.overlay(clone_dir, files, branch) assert 2 == len(glob.glob("{}/*".format(os.path.join(dst_dir, "tests"))))