Exemple #1
0
def test_stats_now_report_as_gtimelog(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--report-as-gtimelog'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = (
        "                                                                time\n"
        "Django: read documentation                                      1 hour 35 min\n"
        "Timeflow: start project                                         1 hour 15 min"
        "\n"
        "\n"
        "Total work done: 2 hours 50 min"
        "\n"
        "\n"
        "By category:"
        "\n"
        "\n"
        "Django                                                          1 hour 35 min\n"
        "Timeflow                                                        1 hour 15 min\n\n"
    )
    assert out == result
Exemple #2
0
def test_stats_now_report(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--report'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = (
        "------------------------------ WORK -------------------------------\n"
        "Django:\n"
        "    1 hour 35 min: read documentation\n"
        "    Total: 1 hour 35 min\n"
        "\n"
        "Timeflow:\n"
        "    1 hour 15 min: start project\n"
        "    Total: 1 hour 15 min\n"
        "------------------------------ SLACK ------------------------------\n"
        "Breakfast:\n"
        "    0 hours 45 min: Breakfast\n"
        "    Total: 0 hours 45 min\n"
        "\n"
        "Slack:\n"
        "    0 hours 25 min: watch YouTube\n"
        "    Total: 0 hours 25 min\n")
    assert out == result
Exemple #3
0
def test_stats_now_report_as_gtimelog(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--report-as-gtimelog'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = (
        "                                                                time\n"
        "Django: read documentation                                      1 hour 35 min\n"
        "Timeflow: start project                                         1 hour 15 min"
        "\n"
        "\n"
        "Total work done: 2 hours 50 min"
        "\n"
        "\n"
        "By category:"
        "\n"
        "\n"
        "Django                                                          1 hour 35 min\n"
        "Timeflow                                                        1 hour 15 min\n\n"
    )
    assert out == result
Exemple #4
0
def test_stats_now_report(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--report'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = (
        "------------------------------ WORK -------------------------------\n"
        "Django:\n"
        "    1 hour 35 min: read documentation\n"
        "    Total: 1 hour 35 min\n"
        "\n"
        "Timeflow:\n"
        "    1 hour 15 min: start project\n"
        "    Total: 1 hour 15 min\n"
        "------------------------------ SLACK ------------------------------\n"
        "Breakfast:\n"
        "    0 hours 45 min: Breakfast\n"
        "    Total: 0 hours 45 min\n"
        "\n"
        "Slack:\n"
        "    0 hours 25 min: watch YouTube\n"
        "    Total: 0 hours 25 min\n"
    )
    assert out == result
Exemple #5
0
def test_edit(patch_datetime_now, tmpdir, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.LOG_FILE = test_dir + '/fake_log.txt'

    # run edit command
    parser = cli.create_parser()
    args = parser.parse_args(['edit'])
    args.func(args)
Exemple #6
0
def test_edit(patch_datetime_now, tmpdir, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run edit command
    parser = cli.create_parser()
    args = parser.parse_args(['edit'])
    args.func(args)
Exemple #7
0
def test_log(patch_datetime_now, tmpdir, capsys):
    tmp_path = tmpdir.join("test_log.txt").strpath
    timeflow.LOG_FILE = tmp_path

    # run log command
    parser = cli.create_parser()
    args = parser.parse_args(['log', 'message'])
    args.func(args)

    with open(tmp_path, 'r') as f:
        lines = f.readlines()
        assert len(lines) == 1
        assert lines[0] == '2015-01-01 23:59: message\n'
Exemple #8
0
def test_log(patch_datetime_now, tmpdir, capsys):
    tmp_path = tmpdir.join("test_log.txt").strpath
    timeflow.utils.LOG_FILE = tmp_path

    # run log command
    parser = cli.create_parser()
    args = parser.parse_args(['log', 'message'])
    args.func(args)

    with open(tmp_path, 'r') as f:
        lines = f.readlines()
        assert len(lines) == 1
        assert lines[0] == '2015-01-01 23:59: message\n'
Exemple #9
0
def test_stats_day(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--day', '2015-01-01'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = ("Work: 2 hours 50 min\n" "Slack: 1 hour 10 min\n")
    assert out == result
Exemple #10
0
def test_stats_day(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--day', '2015-01-01'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = ("Work: 02h 50min\n"
              "Slack: 01h 10min\n")
    assert result == out
Exemple #11
0
def test_stats_from(patch_datetime_now, capsys):
    test_dir = os.path.dirname(os.path.realpath(__file__))

    # overwrite log file setting, to define file to be used in tests
    timeflow.utils.LOG_FILE = test_dir + '/fake_log.txt'

    # run stats command
    parser = cli.create_parser()
    args = parser.parse_args(['stats', '--from', '2014-12-28'])
    args.func(args)

    # extract STDOUT, as stats command prints to it
    out, err = capsys.readouterr()
    result = ("Work: 5 hours 40 min\n"
              "Slack: 2 hours 20 min\n")
    assert out == result