def test_should_run_predefined_task(self): tester = ComponentTester() tester.start('data/SequenceViewer.xml') time.sleep(.500) output = tester.getOutput() assert_that(output, contains_string('DCLs.\nKopiowanie TASKA!'))
def test_should_add_sink(self): tester = ComponentTester() tester.addSink('SampleGenerators:CvMatSink') with open(self.defaultFileName) as file: contents = file.read() assert_that(contents, contains_string( '<Component bump="0" name="Sink" priority="1" type="SampleGenerators:CvMatSink"/>'))
def test_should_add_proper_component_to_task(self): tester = ComponentTester() tester.setComponent('Summator', 'CvBasic:Sum') with open(self.defaultFileName) as file: contents = file.read() assert_that(contents, contains_string('<Component bump="0" name="Summator" priority="1" type="CvBasic:Sum"/>'))
def test_should_stop_on_error_by_default(self): tester = ComponentTester() tester.start('data/SequenceViewer.xml') time.sleep(.500) output = tester.getOutput() assert_that(output, contains_string('Finishing DisCODe.')) assert_that(output, contains_string('Server stoped.'))
def test_should_add_new_datastream(self): tester = ComponentTester() tester.addDataStream('First', 'out_data', 'Second', 'in_data') with open(self.defaultFileName) as file: contents = file.read() assert_that(contents, contains_string('<Source name="First.out_data">\n\t\t\t<sink>Second.in_data</sink>'))
def test_should_add_generator_with_specific_name_to_components(self): tester = ComponentTester() tester.addGenerator('SampleGenerators:CvMatGenerator', 'AnotherGenerator') with open(self.defaultFileName) as file: contents = file.read() assert_that(contents, contains_string( '<Component bump="0" name="AnotherGenerator" priority="1" type="SampleGenerators:CvMatGenerator"/>'))
def test_should_stop_on_termination_statement(self): tester = ComponentTester() tester.resetTerminationStatements() tester.addTerminationStatement('ERROR') tester.start('data/SequenceViewer.xml') time.sleep(.500) output = tester.getOutput() assert_that(output, contains_string('Finishing DisCODe.')) assert_that(output, contains_string('Server stoped.'))
def test_should_stop_discode_manually(self): tester = ComponentTester() tester.resetTerminationStatements() tester.start() time.sleep(5) tester.stop() output = tester.getOutput() assert_that(output, contains_string('Finishing DisCODe.')) assert_that(output, contains_string('Server stoped.'))
def test_should_run_specific_task(self): tester = ComponentTester() tester.resetTerminationStatements() tester.taskName = 'SequenceViewer.xml' tester.start() time.sleep(.500) tester.runner.kill() output = tester.getOutput() assert_that(output, contains_string('Kopiowanie TASKA!'))
def test_should_run_discode(self): tester = ComponentTester() tester.resetTerminationStatements() if isfile(self.defaultFileName): call(['rm', self.defaultFileName]) tester.start() output = tester.getOutput() assert_that(output, contains_string('\x1b[33mWARNING: \x1b[00mConfiguration file config.xml not found.\n'))
def test_should_run_task_with_default_name(self): tester = ComponentTester() tester.resetTerminationStatements() print(call(['pwd'])) if isfile(self.defaultFileName): call(['rm', self.defaultFileName]) tester.start() output = tester.getOutput() assert_that(output, contains_string('Configuration: File \'' + self.defaultFileName + '\' doesn\'t exist.'))
def test_should_print_output_in_debug_mode(self): import sys from io import StringIO from unittest.mock import patch tester = ComponentTester() tester.taskName = 'data/SequenceViewer.xml' tester.setDebugMode(True) tester.start('data/SequenceViewer.xml') # time.sleep(5) output = sys.stdout.getvalue().strip() output = tester.getOutput() assert_that(output, contains_string('\x1b[33mWARNING: \x1b[00mConfiguration file config.xml not found.\n'))
def test_should_check_component_output(self): tester = ComponentTester() # print('adding generator...') tester.addGenerator('SampleGenerators:CvMatGenerator', 'Generator1') tester.addGenerator('SampleGenerators:CvMatGenerator', 'Generator2') # print('adding component...') tester.setComponent('Summator', 'CvBasic:Sum') # print('adding component...') tester.addSink('SampleGenerators:CvMatSink') tester.addDataStream('Generator1', 'out_img', 'Summator', 'in_img1') tester.addDataStream('Generator2', 'out_img', 'Summator', 'in_img2') tester.addDataStream('Summator', 'out_img', 'Sink', 'in_img') tester.addTerminationStatement('END OF SEQUENCE') # print('Task body:') # print(tester.taskBuilder.getTaskBody()) tester.start() output = tester.getOutput() # print(output) # print('finished printing output') assert_that(output, contains_string('[2, 2, 2, 2;\n 2, 2, 2, 2;\n 2, 2, 2, 2]'))