Skip to content

Commit

Permalink
Tested a few untested cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jesper-friis committed Oct 19, 2024
1 parent f1c0958 commit cd5b60e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/dataset/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,26 @@ def test_save_and_load():
assert newfile2.exists()
assert newfile2.stat().st_size == len(buf)

# Test save existing dataset with anonymous distribution
newfile2.unlink(missing_ok=True)
save(ts, buf, dataset=SEMDATA.newimage2)
assert newfile2.exists()
assert newfile2.stat().st_size == len(buf)

# Test save new dataset with reference to existing distribution
newfile2.unlink(missing_ok=True)
save(
ts,
buf,
dataset={
"@id": SEMDATA.newimage3,
"title": "A dataset with no default distribution",
"distribution": SEMDATA.newdistr2,
},
)
assert newfile2.exists()
assert newfile2.stat().st_size == len(buf)

# Test searching the triplestore
SAMPLE = ts.namespaces["sample"]
datasets = list_dataset_iris(ts)
Expand Down
1 change: 0 additions & 1 deletion tests/input/semdata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ generators:
generatorType: application/vnd.dlite-generate
configuration:
driver: hitachi
options: mode=w
2 changes: 1 addition & 1 deletion tripper/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def save(
add(dataset, "distribution", distribution)
triples.append((dataset["@id"], DCAT.distribution, newiri))
save_distribution = True

Check warning on line 175 in tripper/dataset/dataset.py

View check run for this annotation

Codecov / codecov/patch

tripper/dataset/dataset.py#L173-L175

Added lines #L173 - L175 were not covered by tests
elif isinstance(distribution, str):
if isinstance(distribution, str):
distr = load_dict(ts, iri=distribution, use_sparql=use_sparql)
if distr:
distribution = distr
Expand Down

0 comments on commit cd5b60e

Please sign in to comment.