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

[test][algorithm] Update the checks and algorithm name

This change also updates the valid check to print the
error if any should appear making the failure easy to
understand.
parent aa4b2c54
......@@ -73,21 +73,21 @@ class TestLegacyAPI_Loading(unittest.TestCase):
def test_raises_syntax_error(self):
algorithm = Algorithm(prefix, "legacy/syntax_error/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
with self.assertRaises(SyntaxError):
algorithm.runner()
def test_raises_runtime_error(self):
algorithm = Algorithm(prefix, "legacy/syntax_error/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
with self.assertRaises(RuntimeError):
algorithm.runner(exc=RuntimeError)
def test_missing_class_raises(self):
algorithm = Algorithm(prefix, "legacy/no_class/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
with self.assertRaises(AttributeError):
algorithm.runner()
......@@ -102,7 +102,7 @@ class TestLegacyAPI_Loading(unittest.TestCase):
def test_load_valid_algorithm(self):
algorithm = Algorithm(prefix, "legacy/valid_algorithm/1")
self.assertEqual(algorithm.name, "legacy/valid_algorithm/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -120,7 +120,7 @@ class TestLegacyAPI_Loading(unittest.TestCase):
def test_load_valid_analyser(self):
algorithm = Algorithm(prefix, "legacy/valid_analysis/1")
self.assertEqual(algorithm.name, "legacy/valid_analysis/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.output_map) # it is an analyzer
......@@ -147,16 +147,16 @@ class TestLegacyAPI_Loading(unittest.TestCase):
def test_hash(self):
algorithm = Algorithm(prefix, "legacy/valid_analysis/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertEqual(len(algorithm.hash()), 64)
v2 = Algorithm(prefix, "legacy/valid_analysis/2") # only doc changes
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertEqual(algorithm.hash(), v2.hash())
def test_no_description(self):
algorithm = Algorithm(prefix, "legacy/no_doc/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertTrue(algorithm.description is None)
self.assertTrue(algorithm.documentation is None)
......@@ -168,7 +168,7 @@ class TestLegacyAPI_Loading(unittest.TestCase):
def test_description(self):
algorithm = Algorithm(prefix, "legacy/valid_analysis/2") # only doc changes
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertTrue(isinstance(algorithm.description, six.string_types))
self.assertTrue(len(algorithm.description) > 0)
self.assertTrue(algorithm.documentation is None)
......@@ -176,7 +176,7 @@ class TestLegacyAPI_Loading(unittest.TestCase):
def test_analyzer_format(self):
algorithm_name = "legacy/valid_analysis/1"
algorithm = Algorithm(prefix, algorithm_name)
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
dataformat = algorithm.result_dataformat()
self.assertTrue(dataformat.valid)
......@@ -191,7 +191,7 @@ class TestSequentialAPI_Loading(unittest.TestCase):
def test_load_valid_algorithm(self):
algorithm = Algorithm(prefix, "sequential/valid_algorithm/1")
self.assertEqual(algorithm.name, "sequential/valid_algorithm/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -209,7 +209,7 @@ class TestSequentialAPI_Loading(unittest.TestCase):
def test_load_valid_analyser(self):
algorithm = Algorithm(prefix, "sequential/valid_analysis/1")
self.assertEqual(algorithm.name, "sequential/valid_analysis/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.output_map) # it is an analyzer
......@@ -234,10 +234,10 @@ class TestSequentialAPI_Loading(unittest.TestCase):
self.assertFalse(runnable.ready)
self.assertFalse(runnable.prepared)
def test_load_valid_loop(self):
algorithm = Algorithm(prefix, "sequential/loop/1")
self.assertEqual(algorithm.name, "sequential/loop/1")
self.assertTrue(algorithm.valid)
def test_load_valid_loop_evaluator(self):
algorithm = Algorithm(prefix, "sequential/loop_evaluator/1")
self.assertEqual(algorithm.name, "sequential/loop_evaluator/1")
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -246,16 +246,16 @@ class TestSequentialAPI_Loading(unittest.TestCase):
self.assertTrue(algorithm.output_map)
self.assertEqual(algorithm.schema_version, 3)
self.assertEqual(algorithm.api_version, 2)
self.assertEqual(algorithm.type, Algorithm.SEQUENTIAL_LOOP)
self.assertEqual(algorithm.type, Algorithm.SEQUENTIAL_LOOP_EVALUATOR)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
self.assertTrue(runnable.prepared)
def test_load_valid_loop_user(self):
algorithm = Algorithm(prefix, "sequential/loop_user/1")
self.assertEqual(algorithm.name, "sequential/loop_user/1")
self.assertTrue(algorithm.valid)
def test_load_valid_loop_processor(self):
algorithm = Algorithm(prefix, "sequential/loop_processor/1")
self.assertEqual(algorithm.name, "sequential/loop_processor/1")
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -264,7 +264,7 @@ class TestSequentialAPI_Loading(unittest.TestCase):
self.assertTrue(algorithm.output_map)
self.assertEqual(algorithm.schema_version, 3)
self.assertEqual(algorithm.api_version, 2)
self.assertEqual(algorithm.type, Algorithm.SEQUENTIAL_LOOP_USER)
self.assertEqual(algorithm.type, Algorithm.SEQUENTIAL_LOOP_PROCESSOR)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -278,7 +278,7 @@ class TestAutonomousAPI_Loading(unittest.TestCase):
def test_load_valid_algorithm(self):
algorithm = Algorithm(prefix, "autonomous/valid_algorithm/1")
self.assertEqual(algorithm.name, "autonomous/valid_algorithm/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -296,7 +296,7 @@ class TestAutonomousAPI_Loading(unittest.TestCase):
def test_load_valid_analyser(self):
algorithm = Algorithm(prefix, "autonomous/valid_analysis/1")
self.assertEqual(algorithm.name, "autonomous/valid_analysis/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.output_map) # it is an analyzer
......@@ -321,10 +321,10 @@ class TestAutonomousAPI_Loading(unittest.TestCase):
self.assertFalse(runnable.ready)
self.assertFalse(runnable.prepared)
def test_load_valid_loop(self):
algorithm = Algorithm(prefix, "autonomous/loop/1")
self.assertEqual(algorithm.name, "autonomous/loop/1")
self.assertTrue(algorithm.valid)
def test_load_valid_loop_evaluator(self):
algorithm = Algorithm(prefix, "autonomous/loop_evaluator/1")
self.assertEqual(algorithm.name, "autonomous/loop_evaluator/1")
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -333,7 +333,7 @@ class TestAutonomousAPI_Loading(unittest.TestCase):
self.assertTrue(algorithm.output_map)
self.assertEqual(algorithm.schema_version, 3)
self.assertEqual(algorithm.api_version, 2)
self.assertEqual(algorithm.type, Algorithm.AUTONOMOUS_LOOP)
self.assertEqual(algorithm.type, Algorithm.AUTONOMOUS_LOOP_EVALUATOR)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -341,10 +341,10 @@ class TestAutonomousAPI_Loading(unittest.TestCase):
runnable.prepared
) # loop/1 has no prepare method so is prepared
def test_load_valid_loop_user(self):
algorithm = Algorithm(prefix, "autonomous/loop_user/1")
self.assertEqual(algorithm.name, "autonomous/loop_user/1")
self.assertTrue(algorithm.valid)
def test_load_valid_loop_processor(self):
algorithm = Algorithm(prefix, "autonomous/loop_processor/1")
self.assertEqual(algorithm.name, "autonomous/loop_processor/1")
self.assertTrue(algorithm.valid, algorithm.errors)
self.assertFalse(algorithm.errors)
self.assertFalse(algorithm.results) # it is not an analyzer
......@@ -353,7 +353,7 @@ class TestAutonomousAPI_Loading(unittest.TestCase):
self.assertTrue(algorithm.output_map)
self.assertEqual(algorithm.schema_version, 3)
self.assertEqual(algorithm.api_version, 2)
self.assertEqual(algorithm.type, Algorithm.AUTONOMOUS_LOOP_USER)
self.assertEqual(algorithm.type, Algorithm.AUTONOMOUS_LOOP_PROCESSOR)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -370,7 +370,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_crashing_algorithm(self):
algorithm = Algorithm(prefix, self.username + "/setup_crash/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -380,7 +380,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_failing_algorithm(self):
algorithm = Algorithm(prefix, self.username + "/setup_fail/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -389,7 +389,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_nonparametrized_algorithm(self):
algorithm = Algorithm(prefix, self.username + "/no_setup/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -398,7 +398,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_parametrized_algorithm_default_values(self):
algorithm = Algorithm(prefix, self.username + "/parametrized/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -430,7 +430,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_parametrized_algorithm_customized_values(self):
algorithm = Algorithm(prefix, self.username + "/parametrized/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -474,7 +474,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_parametrized_algorithm_out_of_range_value(self):
algorithm = Algorithm(prefix, self.username + "/parametrized/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -484,7 +484,7 @@ class TestLegacyAPI_Setup(unittest.TestCase):
def test_setup_parametrized_algorithm_invalid_choice_value(self):
algorithm = Algorithm(prefix, self.username + "/parametrized/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertFalse(runnable.ready)
......@@ -517,7 +517,7 @@ class TestAutonomousAPI_Setup(TestLegacyAPI_Setup):
class TestLegacyAPI_Prepare(unittest.TestCase):
def test_always_prepared(self):
algorithm = Algorithm(prefix, "legacy/valid_algorithm/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.prepared)
......@@ -530,7 +530,7 @@ class TestLegacyAPI_Prepare(unittest.TestCase):
log_messages = log_handler.messages
algorithm = Algorithm(prefix, "legacy/prepare/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.prepared)
......@@ -555,7 +555,7 @@ class TestSequentialAPI_Prepare(unittest.TestCase):
def test_prepare_crashing_algorithm(self):
algorithm = Algorithm(prefix, self.username + "/prepare_crash/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -567,7 +567,7 @@ class TestSequentialAPI_Prepare(unittest.TestCase):
def test_prepare_failing_algorithm(self):
algorithm = Algorithm(prefix, self.username + "/prepare_fail/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -578,7 +578,7 @@ class TestSequentialAPI_Prepare(unittest.TestCase):
def test_no_preparation_algorithm(self):
algorithm = Algorithm(prefix, self.username + "/no_prepare/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -678,7 +678,7 @@ class TestLegacyAPI_Process(TestExecutionBase):
def test_process_crashing_algorithm(self):
algorithm = Algorithm(prefix, "legacy/process_crash/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -864,7 +864,7 @@ class TestSequentialAPI_Process(TestExecutionBase):
def test_process_crashing_algorithm(self):
algorithm = Algorithm(prefix, "sequential/process_crash/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......@@ -1108,7 +1108,7 @@ class TestAutonomousAPI_Process(TestExecutionBase):
def test_process_crashing_algorithm(self):
algorithm = Algorithm(prefix, "autonomous/process_crash/1")
self.assertTrue(algorithm.valid)
self.assertTrue(algorithm.valid, algorithm.errors)
runnable = algorithm.runner()
self.assertTrue(runnable.ready)
......
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