Skip to content

Commit

Permalink
Always run all behavior check tests and print error message
Browse files Browse the repository at this point in the history
  • Loading branch information
pschillinger committed Mar 1, 2020
1 parent a064398 commit fd8fafd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
60 changes: 37 additions & 23 deletions bin/test_report
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,44 @@
import yaml
import unittest


def generate_test(test_type, test_data):
def test_method(self):
test_function = getattr(self, test_type)
if isinstance(test_data, list):
test_function(*test_data)
else:
test_function(test_data)
return test_method


class TestReport(unittest.TestCase):

def test_report(self):
try:
with open("/tmp/flexbe_app_report.log", 'r') as f:
report = yaml.load(f)
except IOError:
return # skip test since there is no report to evaluate
for test_type, tests in report.items():
for test_name, test_data in tests.items():
if test_type == "assertTrue":
self.assertTrue(test_data, test_name)

def test_behavior_report(self):
try:
with open("/tmp/flexbe_app_behavior_report.log", 'r') as f:
report = yaml.safe_load(f)
except IOError:
return # skip test since there is no report to evaluate
for test_type, tests in report.items():
for test_name, test_data in tests.items():
if test_type == "assertTrue":
self.assertTrue(test_data, test_name)
def test_report(self):
try:
with open("/tmp/flexbe_app_report.log", 'r') as f:
report = yaml.load(f)
except IOError:
return # skip test since there is no report to evaluate
for test_type, tests in report.items():
for test_name, test_data in tests.items():
if test_type == "assertTrue":
self.assertTrue(test_data, test_name)


if __name__ == '__main__':
import rosunit
rosunit.unitrun("flexbe_app", "test_report", TestReport)
try:
with open("/tmp/flexbe_app_behavior_report.log", 'r') as f:
report = yaml.safe_load(f)
except IOError:
pass # add no tests because there is no report to evaluate
else:
for test_type, tests in report.items():
for test_name, test_data in tests.items():
function_name = "test_%s_%s" % (test_name, test_type)
test_function = generate_test(test_type, test_data)
test_function.__name__ = function_name
setattr(TestReport, function_name, test_function)

import rosunit
rosunit.unitrun("flexbe_app", "test_report", TestReport)
2 changes: 1 addition & 1 deletion src/_test/checkbehaviorsreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CheckBehaviorsReport = new (function() {
IO.BehaviorLoader.loadBehavior(m, function(error_string) {
console.log(error_string);
if (error_string != undefined) {
report.assertTrue["behavior_"+behavior] = false;
report.assertTrue["behavior_"+behavior] = [false, error_string];
console.log(behavior+" is false");
}
else{
Expand Down

0 comments on commit fd8fafd

Please sign in to comment.