コード例 #1
0
def test_find_superset():
    assert MetadataStore([{
        "key": "value",
        "version": "1.0.0"
    }]).find({"key": "value"}) == {
        "key": "value",
        "version": "1.0.0"
    }
コード例 #2
0
def test_find_highest_version():
    assert MetadataStore([{
        "version": "1.0.0"
    }, {
        "version": "2.0.0"
    }]).find({}) == {
        "version": "2.0.0"
    }
コード例 #3
0
def test_do_not_find_subset():
    assert (MetadataStore([{
        "key": "value",
        "version": "1.0.0"
    }]).find({
        "key": "value",
        "hello": "world"
    }) == None)
コード例 #4
0
 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)
コード例 #5
0
def test_can_be_initalised_with_None():
    MetadataStore(None)
コード例 #6
0
def test_missing_version_is_ok():
    MetadataStore([{"key": "world"}])
コード例 #7
0
def test_versions_must_be_semver():
    with pytest.raises(ValueError):
        MetadataStore([{"version": 1}])