Exemple #1
0
    def test_create_error_result(self):
        execution_result = ExecutionResult.error(status_code=404,
                                                 message='error')

        assert execution_result.has_error == True
        assert execution_result.error_message == 'error'
        assert execution_result.status_code == 404
def test_get_operation_by_event():
    event = Event(name='event')

    with mock.patch('sdk.coreapi.HttpClient') as mock_client:
        mock_client.get.return_value = ExecutionResult.ok(data=[1])
        operation = get_operation_by_event(event)

        assert operation == 1
def test_get_operation_by_event_fail():
    event = Event(name='event')

    with mock.patch('sdk.coreapi.HttpClient') as mock_client:
        mock_client.get.return_value = ExecutionResult.error(status_code=404, message='error')
        operation = get_operation_by_event(event)

        assert operation is None
Exemple #4
0
def test_create_memory():
    process = {
        'id': 'id',
        'processId': 'process_id',
    }

    event = Event(name="event")

    with mock.patch('sdk.process_memory.HttpClient') as mock_client:
        mock_client.get.return_value = ExecutionResult.ok()
        create_memory(process, event)
def test_create_process_instance_fail():
    operation = {
        'systemId': 'asdf',
        'processId': 'fdsa',
        'version': '1'
    }

    with mock.patch('sdk.coreapi.HttpClient') as mock_client:
        mock_client.post.return_value = ExecutionResult.error(status_code=404, message='error')
        instance = create_process_instance(operation,Event(""))

        assert instance is None
def test_create_process_instance():
    operation = {
        'systemId': 'asdf',
        'processId': 'fdsa',
        'version': '1'
    }

    with mock.patch('sdk.coreapi.HttpClient') as mock_client:
        mock_client.post.return_value = ExecutionResult.ok(data=[1])
        instance = create_process_instance(operation,Event(""))

        assert instance == 1
Exemple #7
0
def test_create_memory_fail():
    process = {
        'id': 'id',
        'processId': 'process_id',
    }

    event = Event(name="event")

    with mock.patch('sdk.process_memory.HttpClient') as mock_client:
        mock_client.get.return_value = ExecutionResult.error(
            message="an error", status_code=404)
        create_memory(process, event)
Exemple #8
0
    def test_create_success_result(self):
        execution_result = ExecutionResult.ok(status_code=200)

        assert execution_result.has_error == False
        assert execution_result.error_message is None
        assert execution_result.status_code == 200