diff --git a/beat/core/test/prefix/algorithms/schema/invalid_loop_output/1.json b/beat/core/test/prefix/algorithms/schema/invalid_loop_output/1.json new file mode 100644 index 0000000000000000000000000000000000000000..97e8978fbe06dab70bdd328a25c728741ea0cce1 --- /dev/null +++ b/beat/core/test/prefix/algorithms/schema/invalid_loop_output/1.json @@ -0,0 +1,29 @@ +{ + "schema_version": 3, + "language": "python", + "api_version": 2, + "type": "loop", + "splittable": false, + "groups": [ + { + "inputs": { + "in": { + "type": "user/single_integer/1" + } + }, + "outputs": { + "out": { + "type": "user/single_integer/1" + } + }, + "loop": { + "request": { + "type": "user/single_integer/1" + }, + "answer": { + "type": "user/single_integer/1" + } + } + } + ] +} diff --git a/beat/core/test/prefix/algorithms/schema/invalid_loop_output/1.py b/beat/core/test/prefix/algorithms/schema/invalid_loop_output/1.py new file mode 100644 index 0000000000000000000000000000000000000000..157d8ffd163fee0033b59c8a023119e46ef76e63 --- /dev/null +++ b/beat/core/test/prefix/algorithms/schema/invalid_loop_output/1.py @@ -0,0 +1,33 @@ +#!/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 diff --git a/beat/core/test/prefix/algorithms/schema/invalid_loop_type/1.json b/beat/core/test/prefix/algorithms/schema/invalid_loop_type/1.json new file mode 100644 index 0000000000000000000000000000000000000000..1448ea9147604b8f8be5fb4e4495fe8cebd29e15 --- /dev/null +++ b/beat/core/test/prefix/algorithms/schema/invalid_loop_type/1.json @@ -0,0 +1,23 @@ +{ + "schema_version": 3, + "language": "python", + "api_version": 2, + "type": "autonomous", + "groups": [ + { + "inputs": { + "in": { + "type": "user/single_integer/1" + } + }, + "loop": { + "request": { + "type": "user/single_integer/1" + }, + "answer": { + "type": "user/single_integer/1" + } + } + } + ] +} diff --git a/beat/core/test/prefix/algorithms/schema/invalid_loop_type/1.py b/beat/core/test/prefix/algorithms/schema/invalid_loop_type/1.py new file mode 100644 index 0000000000000000000000000000000000000000..157d8ffd163fee0033b59c8a023119e46ef76e63 --- /dev/null +++ b/beat/core/test/prefix/algorithms/schema/invalid_loop_type/1.py @@ -0,0 +1,33 @@ +#!/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 diff --git a/beat/core/test/prefix/algorithms/schema/invalid_loop_user_type/1.json b/beat/core/test/prefix/algorithms/schema/invalid_loop_user_type/1.json new file mode 100644 index 0000000000000000000000000000000000000000..399012b7fca61bca0261c7285d457f780ea203d0 --- /dev/null +++ b/beat/core/test/prefix/algorithms/schema/invalid_loop_user_type/1.json @@ -0,0 +1,28 @@ +{ + "schema_version": 3, + "language": "python", + "api_version": 2, + "type": "autonomous", + "groups": [ + { + "inputs": { + "in": { + "type": "user/single_integer/1" + } + }, + "outputs": { + "out": { + "type": "user/single_integer/1" + } + }, + "loop": { + "request": { + "type": "user/single_integer/1" + }, + "answer": { + "type": "user/single_integer/1" + } + } + } + ] +} diff --git a/beat/core/test/prefix/algorithms/schema/invalid_loop_user_type/1.py b/beat/core/test/prefix/algorithms/schema/invalid_loop_user_type/1.py new file mode 100644 index 0000000000000000000000000000000000000000..157d8ffd163fee0033b59c8a023119e46ef76e63 --- /dev/null +++ b/beat/core/test/prefix/algorithms/schema/invalid_loop_user_type/1.py @@ -0,0 +1,33 @@ +#!/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 diff --git a/beat/core/test/test_algorithm_loading.py b/beat/core/test/test_algorithm_loading.py index 9310cf8a07c480f2803487f44ede0e34ea01a29f..47ac6644ef7879567ca6c368678754589eca0e03 100644 --- a/beat/core/test/test_algorithm_loading.py +++ b/beat/core/test/test_algorithm_loading.py @@ -88,6 +88,18 @@ def test_v3(): algorithm = Algorithm(prefix, 'autonomous/loop_user/1') assert algorithm.valid, '\n * %s' % '\n * '.join(algorithm.errors) + +def test_invalid_v3(): + algorithm = Algorithm(prefix, 'schema/invalid_loop_output/1') + assert not algorithm.valid + + algorithm = Algorithm(prefix, 'schema/invalid_loop_type/1') + assert not algorithm.valid + + algorithm = Algorithm(prefix, 'schema/invalid_loop_user_type/1') + assert not algorithm.valid + + #----------------------------------------------------------