Skip to content

Commit

Permalink
Merge branch 'master' into argparser
Browse files Browse the repository at this point in the history
  • Loading branch information
jake authored and jake committed May 2, 2024
2 parents b8a7fc0 + d8f2cc3 commit 6ed3f8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions internetarchive/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def modify_metadata(
secret_key=secret_key,
debug=debug,
request_kwargs=request_kwargs,
refresh=False
)


Expand Down
8 changes: 6 additions & 2 deletions internetarchive/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,8 @@ def modify_metadata(self,
debug: bool = False,
headers: Mapping | None = None,
request_kwargs: Mapping | None = None,
timeout: int | float | None = None) -> Request | Response:
timeout: int | float | None = None,
refresh: bool = True) -> Request | Response:
"""Modify the metadata of an existing item on Archive.org.
Note: The Metadata Write API does not yet comply with the
Expand All @@ -801,6 +802,8 @@ def modify_metadata(self,
:param append_list: Append values to an existing multi-value
metadata field. No duplicate values will be added.
:param refresh: Refresh the item metadata after the request.
:returns: A Request if debug else a Response.
Usage::
Expand Down Expand Up @@ -850,7 +853,8 @@ def modify_metadata(self,
return prepared_request
resp = self.session.send(prepared_request, **request_kwargs)
# Re-initialize the Item object with the updated metadata.
self.refresh()
if refresh:
self.refresh()
return resp

# TODO: `list` parameter name shadows the Python builtin
Expand Down
3 changes: 1 addition & 2 deletions tests/cli/test_ia_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ def test_ia_metadata_modify(capsys):
md_rsp = ('{"success":true,"task_id":447613301,'
'"log":"https://catalogd.archive.org/log/447613301"}')
with IaRequestsMock() as rsps:
rsps.add_metadata_mock('nasa')
rsps.add_metadata_mock('nasa', method=responses.GET)
rsps.add_metadata_mock('nasa', body=md_rsp, method=responses.POST)
rsps.add_metadata_mock('nasa')
valid_key = f'foo-{int(time())}'
ia_call(['ia', 'metadata', '--modify', f'{valid_key}:test_value', 'nasa'])
out, err = capsys.readouterr()
Expand Down

0 comments on commit 6ed3f8a

Please sign in to comment.