예제 #1
0
def add_handler_with_description_test():
    runner = glint.Runner()
    runner['test'] = (default_handler, 'testing')

    assert_equal(2, len(runner._commands))
    assert_equal(default_handler, runner._commands['test']._method)
    assert_equal('testing', runner._commands['test'].description)
예제 #2
0
def create_with_parameters_test():
    runner = glint.Runner(description='test', show_usage=False, prefix='+')

    assert_equal('test', runner._description)
    assert_equal('+', runner._prefix)
    assert_false(runner._show_usage)
    assert_equal(0, len(runner))
예제 #3
0
def create_with_defaults_test():
    runner = glint.Runner()

    assert_equal(None, runner._description)
    assert_equal('--', runner._prefix)
    assert_true(runner._show_usage)
    assert_equal(1, len(runner._commands))
    assert_true('help' in runner._commands)
예제 #4
0
def length_test():
    runner = glint.Runner()
    assert_equal(1, len(runner))

    runner[None] = default_handler
    assert_equal(2, len(runner))

    runner['test'] = test_handler
    assert_equal(3, len(runner))
예제 #5
0
def contains_test():
    runner = glint.Runner()

    runner[None] = default_handler
    runner['test'] = test_handler

    assert_true('help' in runner)
    assert_true(None in runner)
    assert_true('test' in runner)
예제 #6
0
def run_correct_handler_test():
    handler_run = None

    runner = glint.Runner()

    runner[None] = default_handler
    runner['test'] = test_handler

    runner.run(['test'])

    assert_true('test', handler_run)
예제 #7
0
def add_multiple_handlers_test():
    runner = glint.Runner()
    runner[None] = default_handler
    runner['test'] = test_handler

    assert_equal(3, len(runner._commands))

    assert_true(None in runner._commands)
    assert_equal(default_handler, runner._commands[None]._method)

    assert_true('test' in runner._commands)
    assert_equal(test_handler, runner._commands['test']._method)
예제 #8
0
def empty_project(name):
    projects = read_timings()
    if name in projects:
        projects[name].clear()
        write_timings(projects)
    else:
        print(f"{name} {sty.fg.red}not in timings DB: no change.{sty.fg.rs}")


def default():
    print(sty.fg.red, f"something in RED")
    # save_current_timings_file()
    pass


if __name__ == '__main__':
    runner = glint.Runner()
    runner["add"] = (add_project, "add project 'name'")
    runner["del"] = (del_project, "delete project 'name'")
    runner["projects"] = (show_projects, "show projects")
    runner["continue"] = (continue_project,
                          "start/continue working on project 'name'")
    runner["start"] = (continue_project,
                       "start/continue working on project 'name'")
    runner["done"] = (stop, "stop working on project 'name'")
    runner["stop"] = (stop, "stop working on project 'name'")
    runner["empty"] = (empty_project, "remove all entries from project 'name'")
    runner[None] = default
    runner.run()
예제 #9
0
def add_multiple_handlers_with_same_name_test():
    runner = glint.Runner()
    runner['test'] = default_handler
    runner['test'] = test_handler
예제 #10
0
def add_handler_with_different_prefix_test():
    runner = glint.Runner(prefix='+')
    runner[None] = default_handler

    for c in runner._commands:
        assert_equal('+', runner._commands[c]._prefix)
예제 #11
0
def add_handler_with_description_that_is_not_a_method_test():
    runner = glint.Runner()
    runner['test'] = ('foo', 'bar')
예제 #12
0
def add_handler_that_is_not_a_method_test():
    runner = glint.Runner()
    runner['test'] = 'foo'
예제 #13
0
def add_handler_test():
    runner = glint.Runner()
    runner['test'] = default_handler

    assert_equal(2, len(runner._commands))
    assert_equal(default_handler, runner._commands['test']._method)
예제 #14
0
def return_none_when_show_usage_true_test():
    runner = glint.Runner()

    assert_is_none(runner.help())
예제 #15
0
def exception_when_not_enough_parameters_passed_to_command_test():
    runner = glint.Runner(show_usage=False)
    runner['test'] = argument_handler

    runner.run(['test'])
예제 #16
0
def exception_when_no_command_specified_and_no_default_handler_test():
    runner = glint.Runner(show_usage=False)
    runner.run([])
예제 #17
0
def exception_when_unable_to_find_handler_and_show_usage_is_false_test():
    runner = glint.Runner(show_usage=False)
    runner.run(['test'])
예제 #18
0
def return_usage_when_show_usage_is_false_test():
    runner = glint.Runner(show_usage=False)

    help = runner.help()

    assert_is_not_none(help)