def test_command_line_run_successful_json(capsys, monkeypatch):
    monkeypatch.setattr(sys, "argv", [
        'ats_hacker', 'ats_hacker/tests/test_data/simple-job.txt', '-o', 'json'
    ])
    cli = CLI()
    cli.start()
    out, _ = capsys.readouterr()
    want = '{"software": 1, "engineer": 1, "super": 1, "cool": 1, ' \
        '"company": 1, "bozeman": 1, "mt": 1, "or": 1, "remote": 1}\n'
    assert want == out
def test_command_line_with_no_filename(capsys, monkeypatch):
    monkeypatch.setattr(sys, "argv", ['ats_hacker'])
    try:
        cli = CLI()
        cli.start()
    except SystemExit:
        pass
    _, err = capsys.readouterr()
    want = "usage: ats_hacker [-h] [-o [json]] [-r [filename]] filename\n" \
        "ats_hacker: error: the following arguments are required: filename\n"
    assert want == err
def test_command_line_run_successful_pretty(capsys, monkeypatch):
    monkeypatch.setattr(
        sys, "argv",
        ['ats_hacker', 'ats_hacker/tests/test_data/simple-job.txt'])
    try:
        cli = CLI()
        cli.start()
    except SystemExit:
        pass
    out, _ = capsys.readouterr()
    output_words = out.split()
    print(output_words)
    for word in ["Document:", "Word", "Occurances"]:
        assert output_words.index(word)
def test_command_line_print_help_with_dash_h_arg(capsys, monkeypatch):
    monkeypatch.setattr(sys, "argv", ['ats_hacker', '-h'])
    try:
        cli = CLI()
        cli.start()
    except SystemExit:
        pass
    out, _ = capsys.readouterr()
    want = "usage: ats_hacker [-h] [-o [json]] [-r [filename]] filename\n\n" \
        "Keyword aggregator for ATS optimization.\n\n" \
        "positional arguments:\n" \
        "  filename       txt filename for keyword aggregation\n\n" \
        "optional arguments:\n" \
        "  -h, --help     show this help message and exit\n" \
        "  -o [json]      output in raw JSON format\n" \
        "  -r [filename]  txt filename for words to remove\n"
    assert want == out
Beispiel #5
0
def main():
    '''
    load record data
    load vehicle data
    show main menu
    '''
    global debug, gui
    guiType = 0
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hdcg", ["help", "debug", "cli", "gtk"])
    except getopt.GetoptError as err:
        # print help information and exit:
        print(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)


    for o,a in opts:
        if o in ("-d", "--debug"):
            debug=True
        elif o in ("-c", "--cli"):
            guiType = 0
        elif o in ("-g", "--gtk"):
            guiType = 1
        elif o in ("-h", "--help"):
            usage()
            exit()
        else:
            assert False, "unhandled option"

    if debug:
        print('#### DEBUG MODE ####')

    if guiType == 0:
        gui = CLI()
#    elif guiType == 1:
#        gui = GUI()

    FN.load()
    for v in FN.vehicles:
        FN.fuel_graph(v)
    FN.ppl_graph()
    FN.index()
    gui.start() 
Beispiel #6
0
def run():
    cli = CLI()
    cli.start()