Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/tests/test_cookers_base.py
Show All 38 Lines | |||||
def test_simple_cook(): | def test_simple_cook(): | ||||
cooker = BaseVaultCookerMock() | cooker = BaseVaultCookerMock() | ||||
cooker.cook() | cooker.cook() | ||||
cooker.backend.put_bundle.assert_called_once_with( | cooker.backend.put_bundle.assert_called_once_with( | ||||
TEST_OBJ_TYPE, TEST_OBJ_ID, TEST_BUNDLE_CONTENT | TEST_OBJ_TYPE, TEST_OBJ_ID, TEST_BUNDLE_CONTENT | ||||
) | ) | ||||
cooker.backend.set_status.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, "done") | cooker.backend.set_status.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, "done") | ||||
cooker.backend.set_progress.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, None) | cooker.backend.set_progress.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, None) | ||||
cooker.backend.send_notif.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID) | cooker.backend.send_all_notifications.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID) | ||||
def test_code_exception_cook(): | def test_code_exception_cook(): | ||||
cooker = BaseVaultCookerMock() | cooker = BaseVaultCookerMock() | ||||
cooker.prepare_bundle = MagicMock() | cooker.prepare_bundle = MagicMock() | ||||
cooker.prepare_bundle.side_effect = RuntimeError("Nope") | cooker.prepare_bundle.side_effect = RuntimeError("Nope") | ||||
cooker.cook() | cooker.cook() | ||||
# Potentially remove this when we have objstorage streaming | # Potentially remove this when we have objstorage streaming | ||||
cooker.backend.put_bundle.assert_not_called() | cooker.backend.put_bundle.assert_not_called() | ||||
cooker.backend.set_status.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, "failed") | cooker.backend.set_status.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, "failed") | ||||
assert "Nope" not in cooker.backend.set_progress.call_args[0][2] | assert "Nope" not in cooker.backend.set_progress.call_args[0][2] | ||||
cooker.backend.send_notif.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID) | cooker.backend.send_all_notifications.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID) | ||||
def test_policy_exception_cook(): | def test_policy_exception_cook(): | ||||
cooker = BaseVaultCookerMock() | cooker = BaseVaultCookerMock() | ||||
cooker.max_bundle_size = 8 | cooker.max_bundle_size = 8 | ||||
cooker.cook() | cooker.cook() | ||||
# Potentially remove this when we have objstorage streaming | # Potentially remove this when we have objstorage streaming | ||||
cooker.backend.put_bundle.assert_not_called() | cooker.backend.put_bundle.assert_not_called() | ||||
cooker.backend.set_status.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, "failed") | cooker.backend.set_status.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID, "failed") | ||||
assert "exceeds" in cooker.backend.set_progress.call_args[0][2] | assert "exceeds" in cooker.backend.set_progress.call_args[0][2] | ||||
cooker.backend.send_notif.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID) | cooker.backend.send_all_notifications.assert_called_with(TEST_OBJ_TYPE, TEST_OBJ_ID) |