Commit 62773223 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][execution] Implement test for success and failure of prepare method

parent 62818e7c
{
"language": "python",
"splittable": true,
"api_version": 2,
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out_data": {
"type": "user/single_integer/1"
}
}
}
]
}
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.core module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
class Algorithm:
def prepare(self, data_loaders):
return False
def process(self, inputs, outputs):
outputs['out_data'].write(inputs['in_data'].data)
return True
{
"language": "python",
"splittable": true,
"api_version": 2,
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out_data": {
"type": "user/single_integer/1"
}
}
}
]
}
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.core module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
class Algorithm:
def prepare(self, data_loaders):
return True
def process(self, inputs, data_loaders, outputs):
outputs['out_data'].write(inputs['in_data'].data)
return True
{
"analyzers": {
"analysis": {
"algorithm": "user/integers_echo_analyzer/1",
"inputs": {
"in_data": "in"
}
}
},
"blocks": {
"echo": {
"algorithm": "user/prepare_error/1",
"inputs": {
"in_data": "in"
},
"outputs": {
"out_data": "out"
}
}
},
"datasets": {
"set": {
"database": "simple/1",
"protocol": "protocol",
"set": "set"
}
},
"globals": {
"queue": "queue",
"environment": {
"name": "Python 2.7",
"version": "1.3.0"
}
}
}
{
"analyzers": {
"analysis": {
"algorithm": "user/integers_echo_analyzer/1",
"inputs": {
"in_data": "in"
}
}
},
"blocks": {
"echo": {
"algorithm": "user/prepare_success/1",
"inputs": {
"in_data": "in"
},
"outputs": {
"out_data": "out"
}
}
},
"datasets": {
"set": {
"database": "simple/1",
"protocol": "protocol",
"set": "set"
}
},
"globals": {
"queue": "queue",
"environment": {
"name": "Python 2.7",
"version": "1.3.0"
}
}
}
......@@ -80,6 +80,14 @@ class TestDockerExecution(BaseExecutionMixIn):
assert result is None
@slow
def test_single_1_prepare_error(self):
result = self.execute('user/user/single/1/prepare_error', [None])
assert result['status'] == 1
assert result['user_error'] == "'Could not prepare algorithm (returned False)'"
# NOT COMPATIBLE YET WITH THE NEW API
# @slow
# def test_cxx_double_1(self):
......
......@@ -271,6 +271,11 @@ class BaseExecutionMixIn(object):
def test_preprocessing_1(self):
assert self.execute('user/user/preprocessing/1/different_frequencies', [{'sum': 363, 'nb': 8}]) is None
@slow
def test_single_1_prepare_success(self):
assert self.execute('user/user/single/1/prepare_success', [{'out_data': 42}]) is None
# For benchmark purposes
# @slow
# def test_double_1_large(self):
......@@ -298,6 +303,13 @@ class TestLocalExecution(BaseExecutionMixIn):
return LocalExecutor(prefix, configuration, tmp_prefix,
dataformat_cache, database_cache, algorithm_cache)
@slow
def test_single_1_prepare_error(self):
with nose.tools.assert_raises(RuntimeError) as context:
result = self.execute('user/user/single/1/prepare_error', [None])
assert 'Algorithm prepare failed' in context.exception
#----------------------------------------------------------
......@@ -308,3 +320,11 @@ class TestSubprocessExecution(BaseExecutionMixIn):
database_cache, algorithm_cache):
return SubprocessExecutor(prefix, configuration, tmp_prefix,
dataformat_cache, database_cache, algorithm_cache)
@slow
def test_single_1_prepare_error(self):
result = self.execute('user/user/single/1/prepare_error', [None])
assert result['status'] == 1
assert result['user_error'] == "'Could not prepare algorithm (returned False)'"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment