def test_find_superset(): assert MetadataStore([{ "key": "value", "version": "1.0.0" }]).find({"key": "value"}) == { "key": "value", "version": "1.0.0" }
def test_find_highest_version(): assert MetadataStore([{ "version": "1.0.0" }, { "version": "2.0.0" }]).find({}) == { "version": "2.0.0" }
def test_do_not_find_subset(): assert (MetadataStore([{ "key": "value", "version": "1.0.0" }]).find({ "key": "value", "hello": "world" }) == None)
def construct_metadata_store(metadata_filename: Path) -> MetadataStore: """Construct a MetadataStore corresponding to a file. """ metadata_store = None if metadata_filename.exists(): logger.debug("loading metadata from %s", metadata_filename) with open(metadata_filename) as metadata_store_file: metadata_store = yaml.safe_load(metadata_store_file) else: logger.warning("could not find metadata.yaml") return MetadataStore(metadata_store)
def test_can_be_initalised_with_None(): MetadataStore(None)
def test_missing_version_is_ok(): MetadataStore([{"key": "world"}])
def test_versions_must_be_semver(): with pytest.raises(ValueError): MetadataStore([{"version": 1}])