Пример #1
0
    def _create_timesheet(self, text, add_date_to_bottom=False):
        aliases_database.update({
            'foo': Mapping(mapping=(123, 456), backend='test'),
            'bar': Mapping(mapping=(12, 34), backend='test'),
        })
        entries = EntriesCollection(text)
        entries.add_date_to_bottom = add_date_to_bottom

        return Timesheet(entries)
Пример #2
0
    def _create_timesheet(self, text, add_date_to_bottom=False):
        aliases_database.update({
            'foo':
            Mapping(mapping=(123, 456), backend='test'),
            'bar':
            Mapping(mapping=(12, 34), backend='test'),
        })
        entries = EntriesCollection(text)
        entries.add_date_to_bottom = add_date_to_bottom

        return Timesheet(entries)
Пример #3
0
def test_insert_to_top():
    entries_collection = EntriesCollection("""20.01.2014
_internal 0800-0900 Fix coffee machine""")
    entries_collection.add_date_to_bottom = False

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

    assert entries_collection.lines[0].text == "21.01.2014"
    assert entries_collection.lines[1].text == ""
    assert entries_collection.lines[2].text == "taxi 4 Work a bit"
Пример #4
0
def test_insert_to_top():
    entries_collection = EntriesCollection("""20.01.2014
_internal 0800-0900 Fix coffee machine""")
    entries_collection.add_date_to_bottom = False

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

    assert entries_collection.lines[0].text == "21.01.2014"
    assert entries_collection.lines[1].text == ""
    assert entries_collection.lines[2].text == "taxi 4 Work a bit"
Пример #5
0
def test_add_entry_to_entries_collection():
    entries_collection = EntriesCollection(
        "20.01.2014\n_internal 0800-0900 Fix coffee machine")
    entries_collection[datetime.date(2014, 1, 20)].append(
        TimesheetEntry('taxi', 4, 'Work a bit'))

    assert len(entries_collection[datetime.date(2014, 1, 20)]) == 2
Пример #6
0
def test_remove_last_entry_removes_date():
    entries_collection = EntriesCollection(
        "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
Пример #7
0
def test_entries_collection_from_string():
    entries_collection = EntriesCollection(
        "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
Пример #8
0
def test_edit_entry_alias():
    entries_collection = EntriesCollection(
        "20.01.2014\n_internal 0800-0900 Fix coffee machine")
    entries_collection[datetime.date(2014, 1, 20)][0].alias = 'taxi'

    assert entries_collection.lines[
        -1].text == u"taxi      0800-0900 Fix coffee machine"
Пример #9
0
def test_edit_entry_ignored():
    entries_collection = EntriesCollection(
        "20.01.2014\n_internal 0800-0900 Fix coffee machine")
    entries_collection[datetime.date(2014, 1, 20)][0].ignored = True

    assert entries_collection.lines[
        -1].text == u"_internal? 0800-0900 Fix coffee machine"
Пример #10
0
def test_edit_entry_description():
    entries_collection = EntriesCollection(
        "20.01.2014\n_internal 0800-0900 Fix coffee machine")
    entries_collection[datetime.date(2014, 1,
                                     20)][0].description = "Fix printer"

    assert entries_collection.lines[
        -1].text == u"_internal 0800-0900 Fix printer"
Пример #11
0
def create_timesheet(text, add_date_to_bottom=False):
    aliases_database.update({
        'foo': Mapping(mapping=(123, 456), backend='test'),
        'bar': Mapping(mapping=(12, 34), backend='test'),
    })
    parser = TimesheetParser(add_date_to_bottom=add_date_to_bottom)
    entries = EntriesCollection(parser, text)

    return Timesheet(entries)
Пример #12
0
def test_remove_entry_removes_line():
    entries_collection = EntriesCollection(
        "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.lines[
        -1].text == u"_internal 0800-0900 Fix coffee machine"
Пример #13
0
def test_remove_date_removes_lines():
    entries_collection = EntriesCollection("""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.lines[0].text == "21.01.2014"
Пример #14
0
    def _create_timesheet(self, text, add_date_to_bottom=False):
        mappings = {'foo': (123, 456), 'bar': (12, 34)}
        entries = EntriesCollection(text)
        entries.add_date_to_bottom = add_date_to_bottom

        return Timesheet(entries, mappings)
Пример #15
0
def test_timesheet_with_entries():
    entries = EntriesCollection(
        """10.10.2014\nfoo 2 bar\n11.10.2014\nfoo 1 bar""")

    timesheet = Timesheet(entries)
    assert len(timesheet.entries) == 2
Пример #16
0
def test_get_entries():
    entries = EntriesCollection(
        """10.10.2014\nfoo 2 bar\n11.10.2014\nfoo 1 bar""")

    timesheet = Timesheet(entries)
    assert len(timesheet.get_entries(datetime.date(2014, 10, 10))) == 1
Пример #17
0
def test_non_current_workday_entries_ignored():
    entries = EntriesCollection("""04.01.2014\nfoo? 2 bar""")

    timesheet = Timesheet(entries)
    assert len(timesheet.get_non_current_workday_entries()) == 0