def test__build_job_explanation(): iu = InventoryUpdate(id=3, name='I_am_an_Inventory_Update') job_explanation = iu._build_job_explanation() assert job_explanation == 'Previous Task Canceled: {"job_type": "%s", "job_name": "%s", "job_id": "%s"}' % \ ('inventory_update', 'I_am_an_Inventory_Update', 3)
def test_cancel(mocker): with mock.patch.object(UnifiedJob, 'cancel', return_value=True) as parent_cancel: iu = InventoryUpdate() iu.save = mocker.MagicMock() build_job_explanation_mock = mocker.MagicMock() iu._build_job_explanation = mocker.MagicMock(return_value=build_job_explanation_mock) iu.cancel() parent_cancel.assert_called_with(is_chain=False, job_explanation=None)