Skip to content
Snippets Groups Projects
Commit 7767894f authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][loop_executor] Add test for error on validate method

parent b6b8a7db
Branches
Tags v2.1.5
2 merge requests!281.6.x,!27Soft loop
{
"schema_version": 2,
"language": "python",
"api_version": 2,
"type": "loop",
"splittable": false,
"groups": [
{
"inputs": {
"in": {
"type": "user/single_integer/1"
}
},
"loop": {
"input": {
"type": "user/single_integer/1"
},
"output": {
"type": "user/single_integer/1"
}
}
}
]
}
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2018 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.backend.python 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 validate(self, result):
value = result.value
return value < 6
......@@ -43,6 +43,7 @@ from ..loop_executor import Executor as LoopExecutor
from ..loop_executor import LoopMessageHandler
from ..executor import Executor
from ..message_handler import MessageHandler
from ..exceptions import RemoteException
from ..algorithm import Algorithm
from ..dataformat import DataFormat
......@@ -105,6 +106,7 @@ class TestExecution(unittest.TestCase):
self.message_handler = None
self.loop_message_handler = None
self.executor_socket = None
self.loop_executor = None
self.loop_socket = None
self.zmq_context = None
......@@ -114,6 +116,9 @@ class TestExecution(unittest.TestCase):
shutil.rmtree(self.working_dir)
shutil.rmtree(self.loop_working_dir)
if self.loop_executor:
self.loop_executor.wait()
for handler in [self.message_handler, self.loop_message_handler]:
if handler is not None:
handler.kill()
......@@ -201,15 +206,16 @@ class TestExecution(unittest.TestCase):
self.loop_socket = self.zmq_context.socket(zmq.PAIR)
self.loop_socket.connect(self.loop_message_handler.address)
loop_executor = LoopExecutor(self.loop_message_handler, self.loop_working_dir, cache_root=self.cache_root)
self.assertTrue(loop_executor.setup())
self.assertTrue(loop_executor.prepare())
loop_executor.process()
self.loop_executor = LoopExecutor(self.loop_message_handler, self.loop_working_dir, cache_root=self.cache_root)
self.assertTrue(self.loop_executor.setup())
self.assertTrue(self.loop_executor.prepare())
self.loop_executor.process()
executor = Executor(self.executor_socket, self.working_dir, cache_root=self.cache_root, loop_socket=self.loop_socket)
self.assertTrue(executor.setup())
self.assertTrue(executor.prepare())
self.assertTrue(executor.process())
cached_file = CachedDataSource()
......@@ -225,4 +231,9 @@ class TestExecution(unittest.TestCase):
def test_autonomous_loop(self):
self.process('autonomous/loop_user/1',
'autonomous/loop/1')
\ No newline at end of file
'autonomous/loop/1')
def test_autonomous_loop_invalid_output(self):
with self.assertRaises(RemoteException):
self.process('autonomous/loop_user/1',
'autonomous/invalid_loop_output/1')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment