Skip to content
Snippets Groups Projects

Added stricter controls over the returned values by the datasource.

Merged Adham Hashibon requested to merge enforce-error-message-for-incorrect-return-values into master
2 files
+ 62
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -77,6 +77,40 @@ class TestCoreEvaluationDriver(unittest.TestCase):
" the number of output slots"):
driver.application_started()
def test_error_for_incorrect_return_type(self):
def run(self, *args, **kwargs):
return "hello"
ds_factory = self.registry.data_source_factories[0]
ds_factory.run_function = run
driver = CoreEvaluationDriver(application=self.mock_application)
with testfixtures.LogCapture():
with six.assertRaisesRegex(
self,
RuntimeError,
"The run method of data source test_data_source must"
" return a list. It returned instead <.* 'str'>. Fix"
" the run\(\) method to return the appropriate entity."):
driver.application_started()
def test_error_for_incorrect_data_value_entries(self):
def run(self, *args, **kwargs):
return ["hello"]
ds_factory = self.registry.data_source_factories[0]
ds_factory.run_function = run
driver = CoreEvaluationDriver(application=self.mock_application)
with testfixtures.LogCapture():
with six.assertRaisesRegex(
self,
RuntimeError,
"The result list returned by DataSource test_data_source"
" contains an entry that is not a DataValue."
" An entry of type <.* 'str'> was instead found"
" in position 0."
" Fix the DataSource.run\(\) method to"
" return the appropriate entity."
):
driver.application_started()
def test_error_for_missing_ds_output_names(self):
def run(self, *args, **kwargs):
Loading