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
        })
Esempio n. 2
0
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 test_get_failing_scenarios_for_single_pass():
    features = [feature(["passing"])]
    assert [] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_with_unrun_scenarios():
    features = [feature(["passing", "failed", "not-run"])]
    nt.assert_equal([scenario()], behave.get_failing_scenarios(features))
def test_get_failing_scenarios_for_multiple_failing_scenarios():
    features = [feature(["failed", "passing"]), feature(["failed", "passing"])]
    nt.assert_equal([scenario(), scenario()], behave.get_failing_scenarios(features))
def test_get_failing_scenarios_for_pass_and_failure():
    features = [feature(["failed", "passing"])]
    nt.assert_equal([scenario()], behave.get_failing_scenarios(features))
def test_get_failing_scenarios_for_single_pass():
    features = [feature(["passing"])]
    assert [] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_multiple_failing_scenarios():
    features = [feature(["failed", "passing"]),
                feature(["failed", "passing"])]
    assert [scenario(), scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_multiple_failing_scenarios():
    features = [feature(["failed", "passing"]), feature(["failed", "passing"])]
    nt.assert_equal([scenario(), scenario()],
                    behave.get_failing_scenarios(features))
def test_get_failing_scenarios_for_pass_and_failure():
    features = [feature(["failed", "passing"])]
    nt.assert_equal([scenario()], behave.get_failing_scenarios(features))
def test_get_failing_scenarios_for_single_pass():
    features = [feature(["passing"])]
    nt.assert_equal([], behave.get_failing_scenarios(features))
def test_get_failing_scenarios_with_unrun_scenarios():
    features = [feature(["passing", "failed", "not-run"])]
    assert [scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_multiple_failing_scenarios():
    features = [feature(["failed", "passing"]), feature(["failed", "passing"])]
    assert [scenario(), scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_pass_and_failure():
    features = [feature(["failed", "passing"])]
    assert [scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_single_failure():
    features = [feature(["failed"])]
    assert [scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_single_failure():
    features = [feature(["failed"])]
    assert [scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_pass_and_failure():
    features = [feature(["failed", "passing"])]
    assert [scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_with_unrun_scenarios():
    features = [feature(["passing", "failed", "not-run"])]
    nt.assert_equal([scenario()], behave.get_failing_scenarios(features))
def test_get_failing_scenarios_with_unrun_scenarios():
    features = [feature(["passing", "failed", "not-run"])]
    assert [scenario()] == behave.get_failing_scenarios(features)
def test_get_failing_scenarios_for_single_pass():
    features = [feature(["passing"])]
    nt.assert_equal([], behave.get_failing_scenarios(features))