def test_version_of_subdir(tmpfolder): projects = ["main_project", "inner_project"] for project in projects: opts = cli.parse_args([project]) _, opts = api.get_default_options({}, opts) struct, _ = structure.define_structure({}, opts) struct, _ = update.apply_update_rules(struct, opts) structure.create_structure(struct, {}) repo.init_commit_repo(project, struct) shutil.rmtree(os.path.join('inner_project', '.git')) shutil.move('inner_project', 'main_project/inner_project') with utils.chdir('main_project'): main_version = subprocess.check_output( ['python', 'setup.py', '--version']).strip().splitlines()[-1] with utils.chdir('inner_project'): inner_version = subprocess.check_output( ['python', 'setup.py', '--version']).strip().splitlines()[-1] assert main_version.strip() == inner_version.strip()
def test_version_of_subdir(tmpfolder): projects = ["main_project", "inner_project"] for project in projects: opts = cli.parse_args([project]) opts = cli.process_opts(opts) _, opts = api.get_default_options({}, opts) struct, _ = structure.define_structure({}, opts) struct, _ = update.apply_update_rules(struct, opts) structure.create_structure(struct, {}) repo.init_commit_repo(project, struct) shutil.rmtree(os.path.join('inner_project', '.git')) shutil.move('inner_project', 'main_project/inner_project') with utils.chdir('main_project'): main_version = subprocess.check_output([ 'python', 'setup.py', '--version']).strip().splitlines()[-1] with utils.chdir('inner_project'): inner_version = subprocess.check_output([ 'python', 'setup.py', '--version']).strip().splitlines()[-1] assert main_version.strip() == inner_version.strip()
def test_apply_update_rules(tmpfolder): NO_OVERWRITE = structure.FileOp.NO_OVERWRITE NO_CREATE = structure.FileOp.NO_CREATE opts = dict(update=True) struct = {"a": ("a", NO_OVERWRITE), "b": "b", "c": {"a": "a", "b": ("b", NO_OVERWRITE)}, "d": {"a": ("a", NO_OVERWRITE), "b": ("b", NO_CREATE)}, "e": ("e", NO_CREATE)} dir_struct = {"a": "a", "c": {"b": "b"}} exp_struct = {"b": "b", "c": {"a": "a"}, "d": {"a": "a"}} structure.create_structure(dir_struct, opts) res_struct, _ = update.apply_update_rules(struct, opts) assert res_struct == exp_struct
def test_version_of_subdir(tmpfolder): projects = ["main_project", "inner_project"] for project in projects: opts = cli.parse_args([project]) opts = cli.process_opts(opts) _, opts = api.get_default_options({}, opts) struct, _ = structure.define_structure({}, opts) struct, _ = update.apply_update_rules(struct, opts) structure.create_structure(struct, {}) repo.init_commit_repo(project, struct) utils.rm_rf(os.path.join("inner_project", ".git")) shutil.move("inner_project", "main_project/inner_project") with utils.chdir("main_project"): main_version = (subprocess.check_output( [sys.executable, "setup.py", "--version"]).strip().splitlines()[-1]) with utils.chdir("inner_project"): inner_version = (subprocess.check_output( [sys.executable, "setup.py", "--version"]).strip().splitlines()[-1]) assert main_version.strip() == inner_version.strip()
def test_apply_update_rules(tmpfolder): NO_OVERWRITE = structure.FileOp.NO_OVERWRITE NO_CREATE = structure.FileOp.NO_CREATE opts = dict(update=True) struct = { "a": ("a", NO_OVERWRITE), "b": "b", "c": { "a": "a", "b": ("b", NO_OVERWRITE) }, "d": { "a": ("a", NO_OVERWRITE), "b": ("b", NO_CREATE) }, "e": ("e", NO_CREATE) } dir_struct = {"a": "a", "c": {"b": "b"}} exp_struct = {"b": "b", "c": {"a": "a"}, "d": {"a": "a"}} structure.create_structure(dir_struct, opts) res_struct, _ = update.apply_update_rules(struct, opts) assert res_struct == exp_struct