Exemplo n.º 1
0
def test_multi_day_add():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_multi_day_add", "--start", "8:00", "--end", "12:00",
        "--multi_day", "a", "--export", "", "--pause", "30", "--work_time",
        "8:00"
    ]

    db = main(db={})
    day = db[2018][7][29][18]

    assert "a" in day.keys()
    assert day["a"] == {"start": '8:00', "end": '12:00', "pause": 30}

    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_multi_day_add", "--start", "12:00", "--end", "18:00",
        "--multi_day", "b", "--export", "", "--pause", "0", "--work_time",
        "8:00"
    ]

    db = main(db={})
    day = db[2018][7][29][18]

    assert "a" in day.keys() and "b" in day.keys()
    assert day["Arbeitszeit"] == '9:30'
    assert day["Tagessaldo"] == '1:30'
Exemplo n.º 2
0
def test_multi_day_remove_part():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_multi_day_remove_part", "--multi_day", "b", "--export", "",
        "--remove"
    ]

    db = {
        2018: {
            7: {
                29: {
                    18: {
                        "a": {
                            "start": '8:00',
                            "end": '12:00',
                            "pause": 30
                        },
                        "b": {
                            "start": '12:00',
                            "end": '18:00',
                            "pause": 0
                        }
                    }
                }
            }
        }
    }

    db = main(db=db)
    day = db[2018][7][29][18]

    assert "a" in day.keys()
    assert "b" not in day.keys()
Exemplo n.º 3
0
def test_db_from_scratch():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_db_from_scratch", "--work_time", "8:00", "--start", "9:00",
        "--end", "17:30", "--export", ""
    ]

    db = main(db={})

    assert db == {
        2018: {
            7: {
                29: {
                    18: {
                        'start': '9:00',
                        'end': '17:30',
                        'pause': 30,
                        'Arbeitszeit': '8:00',
                        'Tagessaldo': '0:00'
                    },
                    'Wochensaldo': '0:00'
                },
                'Monatssaldo': '0:00'
            },
            'Jahressaldo': '0:00'
        }
    }
Exemplo n.º 4
0
def test_wochenend():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-21", "--user",
        "test_zeitausgleich", "--work_time", "8:00", "--start", "9:00",
        "--end", "18:00", "--pause", "0", "--export", ""
    ]

    db = main(db={})
    day = db[2018][7][29][21]
    assert day["Arbeitszeit"] == day["Tagessaldo"]
    assert "wochenende" in day["comment"].lower()
Exemplo n.º 5
0
def test_urlaub():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user", "test_urlaub",
        "--export", "", "--urlaub"
    ]

    db = main(db={})
    day = db[2018][7][29][18]
    assert "urlaub" in day["comment"].lower()
    assert "start" not in day
    assert "end" not in day
    assert "pause" not in day
    assert day["Tagessaldo"] == "0:00"
Exemplo n.º 6
0
def test_zeitausgleich():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_zeitausgleich", "--work_time", "8:00", "--export", "",
        "--zeitausgleich"
    ]

    db = main(db={})
    day = db[2018][7][29][18]
    assert "zeitausgleich" in day["comment"].lower()
    assert "start" not in day
    assert "end" not in day
    assert "pause" not in day
    assert day["Tagessaldo"] == "-8:00"
def test_pause():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user", "test_pause",
        "--work_time", "8:00", "--start", "8:00", "--end", "18:00", "--export",
        "", "--pause", "0"
    ]

    db = main(db={})
    day = db[2018][7][29][18]
    assert day["start"] == "8:00"
    assert day["end"] == "18:00"
    assert day["pause"] == 0
    assert day["Arbeitszeit"] == "10:00"
    assert day["Tagessaldo"] == "2:00"

    sys.argv[-1] = "30"
    db = main(db={})
    day = db[2018][7][29][18]
    assert day["start"] == "8:00"
    assert day["end"] == "18:00"
    assert day["pause"] == 30
    assert day["Arbeitszeit"] == "9:30"
    assert day["Tagessaldo"] == "1:30"
def test_work_time():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_work_time", "--start", "8:00", "--end", "18:00", "--export", "",
        "--pause", "0", "--work_time", "8:00"
    ]

    # pause is at 0 min and working time is at 8 h
    db = main(db={})
    day = db[2018][7][29][18]
    assert day["pause"] == 0
    assert day["Arbeitszeit"] == "10:00"
    assert day["Tagessaldo"] == "2:00"

    # set pause to 30 min and working time to 8 h
    sys.argv[-4:] = ["--pause", "30", "--work_time", "8:00"]
    db = main(db={})
    day = db[2018][7][29][18]
    assert day["pause"] == 30
    assert day["Arbeitszeit"] == "9:30"
    assert day["Tagessaldo"] == "1:30"

    # set pause to 0 min working time to 7:30 h
    sys.argv[-4:] = ["--pause", "0", "--work_time", "7:30"]
    db = main(db={})
    day = db[2018][7][29][18]
    assert day["pause"] == 0
    assert day["Arbeitszeit"] == "10:00"
    assert day["Tagessaldo"] == "2:30"

    # set pause to 30 min and working time to 7:30
    sys.argv[-4:] = ["--pause", "30", "--work_time", "7:30"]
    db = main(db={})
    day = db[2018][7][29][18]
    assert day["pause"] == 30
    assert day["Arbeitszeit"] == "9:30"
    assert day["Tagessaldo"] == "2:00"
Exemplo n.º 9
0
def test_multi_day_remove_day():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_multi_day_remove_day", "--export", "", "--remove"
    ]

    db = {
        2018: {
            7: {
                29: {
                    17: {
                        "start": '8:00',
                        "end": '18:00',
                        "pause": 30
                    },
                    18: {
                        "a": {
                            "start": '8:00',
                            "end": '12:00',
                            "pause": 30
                        },
                        "b": {
                            "start": '12:00',
                            "end": '18:00',
                            "pause": 0
                        }
                    }
                }
            }
        }
    }

    db = main(db=db)

    with raises(KeyError):
        day = db[2018][7][29][18]
Exemplo n.º 10
0
def test_no_new_day():
    sys.argv[1:] = [
        "--db_path", "/tmp/", "--date", "2018-07-18", "--user",
        "test_no_new_day", "--export", ""
    ]

    db = {
        2018: {
            7: {
                29: {
                    17: {
                        'start': '9:00',
                        'end': '17:30',
                        'pause': 30
                    }
                }
            }
        }
    }

    db = main(db=db)

    with raises(KeyError):
        day = db[2018][7][29][18]