def test_schema_validation(tmpdir, raw_package_config, expected_output): with cwd(tmpdir): Path("packit.json").write_text(raw_package_config) Path("packit.spec").write_text("hello") output = PackitAPI.validate_package_config(Path(".")) assert expected_output in output
def test_schema_validation(tmpdir, raw_package_config, expected_output): with cwd(tmpdir): Path("test_dir").mkdir() Path("test_dir/packit.yaml").write_text(raw_package_config) Path("test_dir/packit.spec").write_text("hello") Path("test_dir/a.md").write_text("a") Path("test_dir/b.md").write_text("b") Path("test_dir/c.txt").write_text("c") output = PackitAPI.validate_package_config(Path("test_dir")) assert expected_output in output
def test_validate_paths(tmpdir, existing_files, existing_directories, raw_package_config, expected_output): with cwd(tmpdir): Path("packit.json").write_text(raw_package_config) Path("packit.spec").write_text("hello") for existing_file in existing_files: Path(existing_file).write_text("") for existing_directory in existing_directories: Path(existing_directory).mkdir() output = PackitAPI.validate_package_config(Path(".")) assert expected_output in output
def validate_config(path_or_url: LocalProject): """ Validate PackageConfig validation. \b - checks missing values - checks incorrect types PATH_OR_URL argument is a local path or a URL to a git repository with packit configuration file """ # we use PackageConfig.load_from_dict for the validation, hence we don't parse it here output = PackitAPI.validate_package_config(path_or_url.working_dir) logger.info(output)