예제 #1
0
def test_edit_entry_ignored():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0800-0900 Fix coffee machine"
    )
    entries_collection[datetime.date(2014, 1, 20)][0].ignored = True

    assert entries_collection.parser.to_text(entries_collection.lines[-1]) == "? _internal 0800-0900 Fix coffee machine"
예제 #2
0
def test_entries_collection_from_string():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0900-1000 Fix coffee machine\ntaxi 2 Work a bit"
    )

    assert len(entries_collection) == 1
    assert len(entries_collection[datetime.date(2014, 1, 20)]) == 2
예제 #3
0
def test_edit_entry_alias():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0800-0900 Fix coffee machine"
    )
    entries_collection[datetime.date(2014, 1, 20)][0].alias = 'taxi'

    assert entries_collection.parser.to_text(entries_collection.lines[-1]) == "taxi      0800-0900 Fix coffee machine"
예제 #4
0
def test_edit_entry_description():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0800-0900 Fix coffee machine"
    )
    entries_collection[datetime.date(2014, 1, 20)][0].description = "Fix printer"

    assert entries_collection.parser.to_text(entries_collection.lines[-1]) == "_internal 0800-0900 Fix printer"
예제 #5
0
def test_remove_last_entry_removes_date():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0800-0900 Fix coffee machine"
    )
    entries_date = datetime.date(2014, 1, 20)
    del entries_collection[entries_date][0]

    assert len(entries_collection.lines) == 0
예제 #6
0
def test_remove_entry_removes_line():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0800-0900 Fix coffee machine\ntaxi 2 Work a bit"
    )
    entries_date = datetime.date(2014, 1, 20)
    del entries_collection[entries_date][1]

    assert len(entries_collection[entries_date]) == 1
    assert entries_collection.parser.to_text(entries_collection.lines[-1]) == "_internal 0800-0900 Fix coffee machine"
예제 #7
0
def test_add_entry_to_entries_collection():
    entries_collection = EntriesCollection(
        TimesheetParser(), "20.01.2014\n_internal 0800-0900 Fix coffee machine"
    )
    entries_collection[datetime.date(2014, 1, 20)].append(
        Entry('taxi', 4, 'Work a bit')
    )

    assert len(entries_collection[datetime.date(2014, 1, 20)]) == 2
예제 #8
0
def test_get_entries_excluding_pushed_excludes_pushed():
    contents = """01.04.2013
foo 2 bar
= bar 0900-1000 bar
foo 1 bar"""
    entries = EntriesCollection(TimesheetParser(), contents)
    timesheet = Timesheet(entries)
    timesheet_entries = timesheet.entries.filter(pushed=False)

    assert len(list(timesheet_entries.values())[0]) == 2
예제 #9
0
def test_remove_date_removes_lines():
    entries_collection = EntriesCollection(TimesheetParser(), """20.01.2014
_internal 0800-0900 Fix coffee machine
taxi 2 Work a bit
21.01.2014
_internal 0800-0900 Fix printer""")

    entries_date = datetime.date(2014, 1, 20)
    del entries_collection[entries_date]

    assert len(entries_collection.lines) == 2
    assert entries_collection.parser.to_text(entries_collection.lines[0]) == "21.01.2014"
예제 #10
0
def test_insert_to_top():
    parser = TimesheetParser(add_date_to_bottom=False)
    entries_collection = EntriesCollection(parser, """20.01.2014
_internal 0800-0900 Fix coffee machine""")

    entries_date = datetime.date(2014, 1, 21)
    entry_line = Entry('taxi', 4, 'Work a bit')
    entries_collection[entries_date].append(entry_line)

    assert entries_collection.parser.to_text(entries_collection.lines[0]) == "21.01.2014"
    assert entries_collection.parser.to_text(entries_collection.lines[1]) == ""
    assert entries_collection.lines[2] == entry_line
예제 #11
0
파일: test_commit.py 프로젝트: gnutix/taxi
def test_failed_entry_doesnt_change_continuation_entry_time(cli, entries_file):
    entries_file.write("""03/07/2017
alias_1 0800-0900 Using a correct alias
fail  -1000 And a failing alias
""")
    cli('commit')

    entries = EntriesCollection(TimesheetParser(),
                                entries=entries_file.read())[datetime.date(
                                    2017, 7, 3)]

    assert entries[0].pushed
    assert not entries[1].pushed
    assert entries[1].duration == (None, datetime.time(10))
예제 #12
0
def test_non_current_workday_entries():
    entries = EntriesCollection(TimesheetParser(), """01.01.2014\nfoo 2 bar""")

    timesheet = Timesheet(entries)
    assert len(timesheet.entries.filter(current_workday=False)) == 1
예제 #13
0
def test_get_entries():
    entries = EntriesCollection(TimesheetParser(), """10.10.2014\nfoo 2 bar\n11.10.2014\nfoo 1 bar""")

    timesheet = Timesheet(entries)
    assert len(timesheet.entries.filter(date=datetime.date(2014, 10, 10))) == 1
예제 #14
0
def test_timesheet_with_entries():
    entries = EntriesCollection(TimesheetParser(), """10.10.2014\nfoo 2 bar\n11.10.2014\nfoo 1 bar""")

    timesheet = Timesheet(entries)
    assert len(timesheet.entries) == 2