def test_config_data_good_data(tmp_path): tmp_path = Path(tmp_path).expanduser().resolve() expected = { "src_path": tmp_path, "commit": None, "old_commit": None, "dst_path": tmp_path, "extra_paths": [tmp_path], "exclude": DEFAULT_EXCLUDE, "original_src_path": None, "skip_if_exists": ["skip_me"], "tasks": ["echo python rulez"], "templates_suffix": ".tmpl", "cleanup_on_error": True, "envops": EnvOps().dict(), "force": False, "only_diff": True, "pretend": False, "quiet": False, "skip": False, "vcs_ref": None, "migrations": (), "secret_questions": (), "subdirectory": None, } conf = ConfigData(**expected) conf.data["_folder_name"] = tmp_path.name expected["answers_file"] = Path(".copier-answers.yml") conf_dict = conf.dict() for key, value in expected.items(): assert conf_dict[key] == value
def test_config_data_good_data(dst): dst = Path(dst).expanduser().resolve() expected = { "src_path": dst, "commit": None, "old_commit": None, "dst_path": dst, "data": DEFAULT_DATA, "extra_paths": [dst], "exclude": DEFAULT_EXCLUDE, "original_src_path": None, "skip_if_exists": ["skip_me"], "tasks": ["echo python rulez"], "templates_suffix": ".tmpl", "cleanup_on_error": True, "envops": EnvOps().dict(), "force": False, "only_diff": True, "pretend": False, "quiet": False, "skip": False, "vcs_ref": None, "migrations": (), "secret_questions": (), "subdirectory": None, } conf = ConfigData(**expected) expected["data"]["_folder_name"] = dst.name expected["answers_file"] = Path(".copier-answers.yml") assert conf.dict() == expected
def test_flags_extra_ignored(): key = "i_am_not_a_member" conf_data = { "src_path": "..", "dst_path": ".", key: "and_i_do_not_belong_here" } confs = ConfigData(**conf_data) assert key not in confs.dict()
def test_config_data_good_data(dst): dst = Path(dst).expanduser().resolve() expected = { "src_path": dst, "dst_path": dst, "data": DEFAULT_DATA, "extra_paths": [dst], "exclude": DEFAULT_EXCLUDE, "include": [], "skip_if_exists": ["skip_me"], "tasks": ["echo python rulez"], "envops": EnvOps(), } conf = ConfigData(**expected) expected["data"]["folder_name"] = dst.name assert conf.dict() == expected