Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/loader/test_client.py
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | def test_status_update(mocker): | ||||
""" | """ | ||||
mocked_put = mocker.patch.object(Session, "request") | mocked_put = mocker.patch.object(Session, "request") | ||||
deposit_client = PrivateApiDepositClient(config=CLIENT_TEST_CONFIG) | deposit_client = PrivateApiDepositClient(config=CLIENT_TEST_CONFIG) | ||||
deposit_client.status_update( | deposit_client.status_update( | ||||
"/update/status", | "/update/status", | ||||
DEPOSIT_STATUS_LOAD_SUCCESS, | DEPOSIT_STATUS_LOAD_SUCCESS, | ||||
revision_id="some-revision-id", | release_id="some-release-id", | ||||
status_detail="foo bar", | status_detail="foo bar", | ||||
) | ) | ||||
mocked_put.assert_called_once_with( | mocked_put.assert_called_once_with( | ||||
"put", | "put", | ||||
"https://nowhere.org/update/status", | "https://nowhere.org/update/status", | ||||
json={ | json={ | ||||
"status": DEPOSIT_STATUS_LOAD_SUCCESS, | "status": DEPOSIT_STATUS_LOAD_SUCCESS, | ||||
"status_detail": "foo bar", | "status_detail": "foo bar", | ||||
"revision_id": "some-revision-id", | "release_id": "some-release-id", | ||||
}, | }, | ||||
) | ) | ||||
def test_status_update_with_no_revision_id(mocker): | def test_status_update_with_no_release_id(mocker): | ||||
"""Reading metadata can fail for some reasons | """Reading metadata can fail for some reasons | ||||
""" | """ | ||||
mocked_put = mocker.patch.object(Session, "request") | mocked_put = mocker.patch.object(Session, "request") | ||||
deposit_client = PrivateApiDepositClient(config=CLIENT_TEST_CONFIG) | deposit_client = PrivateApiDepositClient(config=CLIENT_TEST_CONFIG) | ||||
deposit_client.status_update("/update/status/fail", DEPOSIT_STATUS_LOAD_FAILURE) | deposit_client.status_update("/update/status/fail", DEPOSIT_STATUS_LOAD_FAILURE) | ||||
mocked_put.assert_called_once_with( | mocked_put.assert_called_once_with( | ||||
"put", | "put", | ||||
"https://nowhere.org/update/status/fail", | "https://nowhere.org/update/status/fail", | ||||
json={"status": DEPOSIT_STATUS_LOAD_FAILURE,}, | json={"status": DEPOSIT_STATUS_LOAD_FAILURE,}, | ||||
) | ) |