Skip to content

Commit

Permalink
Update resource API with title and hashing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marksparkza committed Sep 20, 2024
1 parent f3a0209 commit d4a86e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions odp/api/routers/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def output_resource_model(resource: Resource) -> ResourceModel:
filename=resource.filename,
mimetype=resource.mimetype,
size=resource.size,
md5=resource.md5,
hash=resource.hash,
hash_algorithm=resource.hash_algorithm,
timestamp=resource.timestamp.isoformat(),
provider_id=resource.provider_id,
provider_key=resource.provider.key,
Expand Down Expand Up @@ -206,7 +207,8 @@ async def _create_resource(
filename=resource_in.filename,
mimetype=resource_in.mimetype,
size=resource_in.size,
md5=resource_in.md5,
hash=resource_in.hash,
hash_algorithm=resource_in.hash_algorithm,
timestamp=(timestamp := datetime.now(timezone.utc)),
provider_id=resource_in.provider_id,
)
Expand Down
12 changes: 8 additions & 4 deletions test/api/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def assert_db_state(resources):
assert row.filename == resources[n].filename
assert row.mimetype == resources[n].mimetype
assert row.size == resources[n].size
assert row.md5 == resources[n].md5
assert row.hash == resources[n].hash
assert row.hash_algorithm == resources[n].hash_algorithm
assert row.provider_id == resources[n].provider_id
assert_new_timestamp(row.timestamp)

Expand Down Expand Up @@ -96,7 +97,8 @@ def assert_json_result(response, json, resource):
assert json['filename'] == resource.filename
assert json['mimetype'] == resource.mimetype
assert json['size'] == resource.size
assert json['md5'] == resource.md5
assert json['hash'] == resource.hash
assert json['hash_algorithm'] == resource.hash_algorithm
assert json['provider_id'] == resource.provider_id
assert json['provider_key'] == resource.provider.key
assert json['archive_paths'] == resource.archive_paths
Expand Down Expand Up @@ -369,7 +371,8 @@ def _test_create_resource(
filename=resource.filename,
mimetype=resource.mimetype,
size=resource.size,
md5=resource.md5,
hash=resource.hash,
hash_algorithm=resource.hash_algorithm,
provider_id=resource.provider_id,
archive_id=archive.id,
archive_path=resource.archive_paths[archive.id],
Expand Down Expand Up @@ -451,7 +454,8 @@ def _test_create_resource_conflict(
filename=resource.filename,
mimetype=resource.mimetype,
size=resource.size,
md5=resource.md5,
hash=resource.hash,
hash_algorithm=resource.hash_algorithm,
provider_id=resource.provider_id,
archive_id=ar.archive_id,
archive_path=ar.path,
Expand Down

0 comments on commit d4a86e6

Please sign in to comment.