Exemplo n.º 1
0
def test_timetracker_task_summary_day_correct_total():
    timesheet = Timesheet()
    timesheet.append(Event(datetime(1985, 10, 26, 1, 21), 'Destination Time'))
    timesheet.append(Event(datetime(1985, 10, 26, 1, 22), 'Present Time'))
    timetracker = Timetracker(timesheet)
    tasks = timetracker.task_summary_by_day(date(1985, 10, 26))
    assert (approx(1 / 60), 'Destination Time') == tasks[0]
Exemplo n.º 2
0
def test_timesheet_summarise_gives_task_list(empty_timesheet):
    # For an arbitrary value of now
    empty_timesheet.append(Event(datetime(2018, 8, 31, 18, 50), 'Now'))
    # If I'm not typing that quickly
    empty_timesheet.append(Event(datetime(2018, 8, 31, 18, 51), 'Also now'))

    tasks = empty_timesheet.summarise()
    assert 1 == len(tasks)
Exemplo n.º 3
0
def test_event_properties_match():
    """Event properties are equal to parameters"""

    when = datetime(1985, 10, 26, 1, 22)
    what = 'Something happened'
    event = Event(when, what)
    assert when == event.when
    assert what == event.what
Exemplo n.º 4
0
def dup_timesheet():
    timesheet = Timesheet()
    data = [
        (datetime(2018, 9, 2, 15, 0), 'Implement Task grouping'),
        (datetime(2018, 9, 2, 15, 10), 'Implement Task grouping'),
        (datetime(2018, 9, 2, 15, 15), 'Complete Task grouping'),
    ]
    for event in data:
        timesheet.append(Event(*event))
    return timesheet
Exemplo n.º 5
0
def test_storage_persist_succeeds(empty_timesheet, storage_adaptor_mock):
    """Storage port can persist data"""

    empty_timesheet.append(
        Event(datetime(1985, 10, 26, 1, 21), 'Destination Time'))
    storage = Storage(empty_timesheet, storage_adaptor_mock)
    storage.persist()
    storage_adaptor_mock.store.assert_called_once()
    first_argument = storage_adaptor_mock.store.call_args[0][0]
    assert (datetime(1985, 10, 26, 1,
                     21), 'Destination Time') == next(first_argument)
Exemplo n.º 6
0
def bttf_timesheet():
    timesheet = Timesheet()
    data = [
        (datetime(1955, 11, 5, 6, 15), 'Arrival'),
        (datetime(1955, 11, 12, 22, 4), 'Lightning Strike'),
        (datetime(1985, 10, 26, 1, 20), 'Last Time Departed'),
        (datetime(1985, 10, 26, 1, 21), 'Destination Time'),
        (datetime(1985, 10, 26, 1, 22), 'Present Time'),
        (datetime(1985, 10, 26, 1, 35), 'Escape'),
    ]
    for event in data:
        timesheet.append(Event(*event))
    return timesheet
Exemplo n.º 7
0
def test_timesheet_append_event_succeeds(empty_timesheet):
    """Can append an event to a timesheet"""

    empty_timesheet.append(Event(datetime.now(), 'Something happened'))
    assert 1 == len(empty_timesheet)
Exemplo n.º 8
0
def test_event_created():
    """Create an event"""

    event = Event(datetime.now(), 'Something happened')
    assert isinstance(event, Event)