Skip to content

Commit

Permalink
Added CI
Browse files Browse the repository at this point in the history
  • Loading branch information
spikelynch committed Dec 9, 2024
1 parent ae6f7eb commit d1c5bf2
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dev = [
"pytest-httpserver>=1.1.0",
"pytest>=8.3.4",
"ruff>=0.8.2",
"pre-commit>=4.0.1",
]
6 changes: 3 additions & 3 deletions src/rocrate_abstract/rocrate_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def add(self, t, i, props):

def all(self):
"""dunno about this"""
return [TinyEntity(self, e) for e in self.graph]
return [Entity(self, e) for e in self.graph]

def get(self, i):
es = [e for e in self.graph if e["@id"] == i]
if es:
return TinyEntity(self, es[0])
return Entity(self, es[0])
else:
return None

Expand All @@ -67,7 +67,7 @@ def write_json(self, crate_dir):
json.dump({"@context": self.context, "@graph": self.graph}, jfh, indent=2)


class TinyEntity:
class Entity:
def __init__(self, crate, ejsonld):
self.crate = crate
self.type = ejsonld["@type"]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_crates.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_crate(tmp_path):
jcrate.write_json(Path(tmp_path))
with open(jsonf, "r") as jfh:
jsonld = json.load(jfh)
jcrate2 = TinyCrate(jsonld=jsonld)
jcrate2 = Crate(jsonld=jsonld)
for i in range(1000):
eid = f"#ds{i:05d}"
ea = jcrate.get(eid)
Expand All @@ -36,7 +36,7 @@ def test_load_file(crates):
cratedir = crates["textfiles"]
with open(Path(cratedir) / "ro-crate-metadata.json", "r") as jfh:
jsonld = json.load(jfh)
crate = TinyCrate(jsonld=jsonld, directory=cratedir)
crate = Crate(jsonld=jsonld, directory=cratedir)
tfile = crate.get("doc001/textfile.txt")
contents = tfile.fetch()
with open(Path(cratedir) / "doc001" / "textfile.txt", "r") as tfh:
Expand All @@ -56,7 +56,7 @@ def test_load_url(crates, httpserver: HTTPServer):
cratedir = crates["textfiles"]
with open(Path(cratedir) / "ro-crate-metadata.json", "r") as jfh:
jsonld = json.load(jfh)
crate = TinyCrate(jsonld=jsonld, directory=cratedir)
crate = Crate(jsonld=jsonld, directory=cratedir)
# add an entity to the crate with the endpoint URL as the id
urlid = httpserver.url_for("/textfileonurl.txt")
crate.add("File", urlid, {"name": "textfileonurl.txt"})
Expand Down
Loading

0 comments on commit d1c5bf2

Please sign in to comment.