def test_add_generator_source(): metadata.reset() metadata.add_generator_source(name="name", version="1.2.3") current = metadata.get() assert current.sources[0].generator.name == "name" assert current.sources[0].generator.version == "1.2.3"
def test_disable_writing_metadata(source_tree: SourceTree): metadata_path: pathlib.Path = source_tree.tmpdir / "synth.metadata" try: with metadata.MetadataTrackerAndWriter(metadata_path): metadata.add_generator_source(name="a-generator", version="1", docker_image="x") metadata.add_generator_source(name="b-generator", version="2", docker_image="y") metadata.enable_write_metadata(False) assert not metadata_path.exists() finally: metadata.enable_write_metadata(True)
def test_git_sources_are_sorted(source_tree: SourceTree): metadata_path = source_tree.tmpdir / "synth.metadata" with metadata.MetadataTrackerAndWriter(metadata_path): metadata.add_generator_source(name="a-generator", version="1", docker_image="x") metadata.add_generator_source(name="b-generator", version="2", docker_image="y") metadata.add_template_source(name="a-template", origin="andromeda", version="3") metadata.add_template_source(name="b-template", origin="milky way", version="4") metadata.add_git_source(name="a-git", sha="1a") metadata.add_git_source(name="b-git", sha="1b") m1 = metadata._read_or_empty(metadata_path) # Add the same sources in reverse order. metadata.reset() with metadata.MetadataTrackerAndWriter(metadata_path): metadata.add_git_source(name="b-git", sha="1b") metadata.add_git_source(name="a-git", sha="1a") metadata.add_template_source(name="b-template", origin="milky way", version="4") metadata.add_template_source(name="a-template", origin="andromeda", version="3") metadata.add_generator_source(name="b-generator", version="2", docker_image="y") metadata.add_generator_source(name="a-generator", version="1", docker_image="x") m2 = metadata._read_or_empty(metadata_path) assert m1.sources == m2.sources
def _report_metadata(self): metadata.add_generator_source(name="artman", version=self.version, docker_image=self.docker_image)