Skip to content

Commit

Permalink
cli check_zephir uses Item check_zephir method
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Dec 6, 2024
1 parent f392727 commit 32a79dd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 83 deletions.
5 changes: 3 additions & 2 deletions aim/cli/digifeeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ def check_zephir(
"""

print(f"Checking Zephir for {barcode}")
item = functions.check_zephir(barcode)
if item:
item = get_item(barcode)
result = item.check_zephir()
if result:
S.logger.info("in_zephir", message="Item is in zephir", barcode=barcode)
else:
S.logger.info("not_in_zephir", message="Item is NOT in zephir", barcode=barcode)
Expand Down
13 changes: 0 additions & 13 deletions aim/digifeeds/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,3 @@ def list_barcodes_in_input_bucket():
response = s3.list_objects_v2(Bucket=S.digifeeds_s3_bucket, Prefix=prefix)
barcodes = [Path(object["Key"]).stem for object in response["Contents"]]
return barcodes


def check_zephir(barcode: str):
item = Item(DBClient().get_or_add_item(barcode))
if item.has_status("in_zephir"):
return item

response = requests.get(f"{S.zephir_bib_api_url}/mdp.{barcode}")
if response.status_code == 200:
DBClient().add_item_status(barcode=barcode, status="in_zephir")
return item
else:
return None
2 changes: 1 addition & 1 deletion tests/cli/test_digifeeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_add_to_db_where_item_is_not_in_digifeeds_set(item_data):
assert "added_to_digifeeds_set" in result.stdout


def test_add_to_db_where_item_is_not_in_alma(item_data, mocker):
def test_add_to_db_where_item_is_not_in_alma(mocker):
item_mock = mocker.MagicMock(Item)
item_mock.has_status.side_effect = [True, False]
item_mock.add_to_digifeeds_set.return_value = item_mock
Expand Down
67 changes: 0 additions & 67 deletions tests/digifeeds/test_check_zephir.py

This file was deleted.

0 comments on commit 32a79dd

Please sign in to comment.