def run(argv): opts = util.parse_docopt(__doc__, argv, False) biobox = opts['<biobox_type>'] image = opts['<image>'] task = opts['--task'] verbose = opts['--verbose'] log = opts['--log'] if not behave.features_available(biobox): error.err_exit("unknown_command", { "command_type": "biobox type", "command": biobox }) ctn.exit_if_no_image_available(image) if verbose: results = behave.run(biobox, image, task, False) else: results = behave.run(biobox, image, task) if verbose: if log: sys.stdout = open(log, "w+") statuses = fn.thread([ behave.get_scenarios_and_statuses(results), F(map, lambda x: name_and_status(*x)), F(list) ]) longest_name = fn.thread( [statuses, F(map, fn.first), F(map, len), max]) def justify(x, y): return x.ljust(longest_name), y output = fn.thread([ statuses, F(map, lambda x: justify(*x)), F(map, F(" ".join)), fn.unique, F("\n".join) ]) print(output) if behave.is_failed(results): exit(1) elif behave.is_failed(results): if log: sys.stderr = open(log, "w+") msg = fn.thread([ behave.get_failing_scenarios(results), F(map, behave.scenario_name), F("\n".join) ]) error.err_exit('failed_verification', { 'image': image, 'error': msg, 'biobox': biobox })
def run(argv): opts = util.parse_docopt(__doc__, argv, False) biobox = opts['<biobox_type>'] image = opts['<image>'] task = opts['--task'] verbose = opts['--verbose'] log = opts['--log'] if not behave.features_available(biobox): error.err_exit("unknown_command", {"command_type" : "biobox type", "command" : biobox}) ctn.exit_if_no_image_available(image) if verbose: results = behave.run(biobox, image, task, False) else: results = behave.run(biobox, image, task) if verbose: if log: sys.stdout = open(log, "w+") statuses = fn.thread([ behave.get_scenarios_and_statuses(results), F(map, lambda x: name_and_status(*x)), F(list)]) longest_name = fn.thread([ statuses, F(map, fn.first), F(map, len), max]) def justify(x, y): return x.ljust(longest_name), y output = fn.thread([ statuses, F(map, lambda x: justify(*x)), F(map, F(" ".join)), fn.unique, F("\n".join)]) print(output) if behave.is_failed(results): exit(1) elif behave.is_failed(results): if log: sys.stderr = open(log, "w+") msg = fn.thread([ behave.get_failing_scenarios(results), F(map, behave.scenario_name), F("\n".join)]) error.err_exit('failed_verification', {'image': image, 'error': msg, 'biobox' : biobox})
def format_scenario_name(name): return fn.thread([ str.replace(name, "Should ", ""), lambda x: x[0].upper() + x[1:], F(flip(str.split), '--'), fn.first, str.strip])
def get_scenarios_and_statuses(behave_data): """ Returns a list of scenarios and their status """ return fn.thread([ get_scenarios(behave_data), F(map, lambda x: [scenario_name(x), scenario_status(x)])])
def format_scenario_name(name): return fn.thread([ string.replace(name, "Should ", ""), lambda x: x[0].upper() + x[1:], F(flip(string.split), '--'), fn.first, string.strip])
def input_args(): """ Get command line args excluding those consisting of only whitespace """ return fn.thread([ sys.argv[1:], F(map, str.strip), F(filter, fn.is_not_empty)])
def input_args(): """ Get command line args excluding those consisting of only whitespace """ return fn.thread([ sys.argv[1:], F(map, string.strip), F(filter, fn.is_not_empty)])
def get_scenarios_and_statuses(behave_data): """ Returns a list of scenarios and their status """ return fn.thread([ get_scenarios(behave_data), F(map, lambda x: [scenario_name(x), scenario_status(x)]) ])
def scenario_status(scenario): """ Returns the status of the last step in a scenario """ status = fn.thread([ scenario['steps'], F(map, fn.get("result")), F(filter, fn.is_not_none), F(map, fn.get("status")), ]) if fn.is_empty(status): return "not run" else: return status[-1]
def scenario_status(scenario): """ Returns the status of the last step in a scenario """ status = fn.thread([ scenario['steps'], F(map, fn.get("result")), F(filter, fn.is_not_none), F(map, fn.get("status")), ]) if fn.is_empty(status): return "not run" else: return status[-1]
def test_thread(): args = [1, F(op.add, 2), F(op.mul, 3)] nose.assert_equal(9, fn.thread(args))
def test_thread(): args = [1, F(op.add, 2), F(op.mul, 3)] nose.assert_equal(9, fn.thread(args))
def test_thread(): args = [1, F(op.add, 2), F(op.mul, 3)] assert 9 == fn.thread(args)