def test_run_exception(self, mCreateSession, mSample): mSample.return_value = 'XXX' iSession = MockSession() mCreateSession.return_value = (iSession, '123456') client = iSession.client('stepfunctions') client.list_activities.return_value = { 'activities': [{ 'name': 'name', 'activityArn': 'XXX' }] } activity = ActivityMixin() def stop_loop(*args, **kwargs): activity.polling = False raise BossError(None) client.get_activity_task.side_effect = stop_loop activity.run('name') calls = [ mock.call.list_activities(), mock.call.get_activity_task(activityArn='XXX', workerName='name-XXX') ] self.assertEqual(client.mock_calls, calls)
def test_run(self, mCreateSession, mSample): mSample.return_value = 'XXX' iSession = MockSession() mCreateSession.return_value = (iSession, '123456') client = iSession.client('stepfunctions') client.list_activities.return_value = { 'activities': [{ 'name': 'name', 'activityArn': 'XXX' }] } client.get_activity_task.return_value = { 'taskToken': 'YYY', 'input': '{}' } target = mock.MagicMock() activity = ActivityMixin(handle_task=target) def stop_loop(*args, **kwargs): activity.polling = False return mock.DEFAULT target.side_effect = stop_loop activity.run('name') calls = [ mock.call.list_activities(), mock.call.get_activity_task(activityArn='XXX', workerName='name-XXX') ] self.assertEqual(client.mock_calls, calls) calls = [mock.call('YYY', {}), mock.call().start()] self.assertEqual(target.mock_calls, calls)