Beispiel #1
0
def test_swf_exception_wrapper_with_non_client_error():
    exception = RuntimeError("Not handled by swf_exception_wrapper")
    with pytest.raises(RuntimeError) as exc:
        with swf_exceptions.swf_exception_wrapper():
            raise exception

    assert exc.value == exception
 def record_heartbeat(self, details, task_token):
     with swf_exception_wrapper():
         response_data = self._swf_client.record_activity_task_hearbeat(details=details, taskToken=task_token)
     if response_data['cancelRequested']:
         raise CancellationError()
 def cancel(self, details, task_token):
     with swf_exception_wrapper():
         self._swf_client.respond_activity_task_cancelled(details=details, taskToken=task_token)
 def fail(self, details, task_token, reason=''):
     details = self.data_converter.dumps(details)
     with swf_exception_wrapper():
         self._swf_client.respond_activity_task_failed(details=details, reason=reason, taskToken=task_token)
 def complete(self, result, task_token):
     result = self.data_converter.dumps(result)
     with swf_exception_wrapper():
         self._swf_client.respond_activity_task_completed(result=result, taskToken=task_token)
Beispiel #6
0
def test_swf_exception_wrapper_with_no_exception():
    with swf_exceptions.swf_exception_wrapper():
        pass # nothing went wrong
Beispiel #7
0
def test_swf_exception_wrapper_with_malformed_code_key():
    with pytest.raises(swf_exceptions.SWFResponseError) as exc:
        with swf_exceptions.swf_exception_wrapper():
            raise ClientError({'Error': {'Code': (123, "this is not a key"), 'Message': None}}, 'foobar')
Beispiel #8
0
def test_swf_exception_wrapper_with_known_exception(code_key, expected_exception):
    with pytest.raises(expected_exception) as exc:
        with swf_exceptions.swf_exception_wrapper():
            raise ClientError({'Error': {'Code': code_key, 'Message': 'Oops'}}, 'foobar')

    assert str(exc.value) == "Oops"
Beispiel #9
0
def test_swf_exception_wrapper_with_no_error_response_details():
    with pytest.raises(swf_exceptions.SWFResponseError) as exc:
        with swf_exceptions.swf_exception_wrapper():
            raise ClientError({'Error': {'Code': None, 'Message': None}}, 'foobar')
Beispiel #10
0
def test_swf_exception_wrapper_with_unknown_exception():
    with pytest.raises(swf_exceptions.SWFResponseError) as exc:
        with swf_exceptions.swf_exception_wrapper():
            raise ClientError({'Error': {'Code': 'SomethingBrokeError', 'Message': 'Oops'}}, 'foobar')

    assert str(exc.value) == "Oops"
Beispiel #11
0
 def record_heartbeat(self, details, task_token):
     with swf_exception_wrapper():
         response_data = self._swf_client.record_activity_task_hearbeat(
             details=details, taskToken=task_token)
     if response_data['cancelRequested']:
         raise CancellationError()
Beispiel #12
0
 def cancel(self, details, task_token):
     with swf_exception_wrapper():
         self._swf_client.respond_activity_task_cancelled(
             details=details, taskToken=task_token)
Beispiel #13
0
 def fail(self, details, task_token, reason=''):
     details = self.data_converter.dumps(details)
     with swf_exception_wrapper():
         self._swf_client.respond_activity_task_failed(details=details,
                                                       reason=reason,
                                                       taskToken=task_token)
Beispiel #14
0
 def complete(self, result, task_token):
     result = self.data_converter.dumps(result)
     with swf_exception_wrapper():
         self._swf_client.respond_activity_task_completed(
             result=result, taskToken=task_token)