def test_apply_update_rules(tmpdir): # noqa NO_OVERWRITE = structure.FileOp.NO_OVERWRITE NO_CREATE = structure.FileOp.NO_CREATE rules = {"a": NO_OVERWRITE, "c": {"b": NO_OVERWRITE}, "d": {"a": NO_OVERWRITE, "b": NO_CREATE, "c": NO_CREATE, "d": NO_OVERWRITE}, "e": NO_CREATE} struct = {"a": "a", "b": "b", "c": {"a": "a", "b": "b"}, "d": {"a": "a", "b": "b"}, "e": "e"} dir_struct = {"a": "a", "c": {"b": "b"}} exp_struct = {"b": "b", "c": {"a": "a"}, "d": {"a": "a"}} structure.create_structure(dir_struct) res_struct = structure.apply_update_rules(rules, struct) assert res_struct == exp_struct
def test_apply_update_rules(tmpdir): # noqa NO_OVERWRITE = structure.FileOp.NO_OVERWRITE NO_CREATE = structure.FileOp.NO_CREATE rules = { "a": NO_OVERWRITE, "c": { "b": NO_OVERWRITE }, "d": { "a": NO_OVERWRITE, "b": NO_CREATE, "c": NO_CREATE, "d": NO_OVERWRITE }, "e": NO_CREATE } struct = { "a": "a", "b": "b", "c": { "a": "a", "b": "b" }, "d": { "a": "a", "b": "b" }, "e": "e" } dir_struct = {"a": "a", "c": {"b": "b"}} exp_struct = {"b": "b", "c": {"a": "a"}, "d": {"a": "a"}} structure.create_structure(dir_struct) res_struct = structure.apply_update_rules(rules, struct) 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 = api.get_default_options({}, opts) struct, _ = structure.define_structure({}, opts) struct, _ = structure.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 = api.get_default_options({}, opts) struct, _ = structure.define_structure({}, opts) struct, _ = structure.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, _ = structure.apply_update_rules(struct, opts) assert res_struct == exp_struct
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, _ = structure.apply_update_rules(struct, opts) assert res_struct == exp_struct