def test_readme_partials(): cwd = os.getcwd() os.chdir(FIXTURES) data = partials.load_partials() # should have populated introduction from partial. assert "objects to users via direct download" in data["introduction"] os.chdir(cwd)
def _load_generic_metadata(self, metadata: Dict): """ loads additional meta information from .repo-metadata.json. """ metadata["partials"] = partials.load_partials() # Loads repo metadata information from the default location if it # hasn't already been set. Some callers may have already loaded repo # metadata, so we don't need to do it again or overwrite it. Also, only # set the "repo" key. if "repo" not in metadata: metadata["repo"] = _load_repo_metadata()
def custom_templates(files: List[str], **kwargs) -> None: """Generate custom template files Fetches information about the repository from the .repo-metadata.json file, information about the latest artifact versions and copies the files into their expected location. Args: files (List[str], optional): List of template paths to include **kwargs: Additional options for CommonTemplates.render() """ kwargs["metadata"] = _common_template_metadata() kwargs["metadata"]["partials"] = partials.load_partials() for file in files: template = gcp.CommonTemplates().render(file, **kwargs) s.copy([template])
def test_readme_partials_not_found(): data = partials.load_partials(["non-existent.yaml"]) assert len(data) == 0
def test_readme_partials(): with util.chdir(FIXTURES): data = partials.load_partials() # should have populated introduction from partial. assert "objects to users via direct download" in data["introduction"]