Пример #1
0
def test_create_multiple_tasks():
    tasks = todos.new()

    todos.create_task(
        tasks, 'Email team updates',
        description='Some more details',
        due_on=datetime(2018, 3, 1, 9))

    assert tasks == [{
        'task': 'Email team updates',
        'description': 'Some more details',
        'due_on': datetime(2018, 3, 1, 9),
        'status': 'pending'
    }]

    todos.create_task(
        tasks, 'Update project plan',
        description='Important before investors meeting',
        due_on=datetime(2018, 3, 5, 9))

    assert tasks == [{
        'task': 'Email team updates',
        'description': 'Some more details',
        'due_on': datetime(2018, 3, 1, 9),
        'status': 'pending'
    }, {
        'task': 'Update project plan',
        'description': 'Important before investors meeting',
        'due_on': datetime(2018, 3, 5, 9),
        'status': 'pending'
    }]
Пример #2
0
def create(ctx, name, description, due_on):
    tasks = ctx.obj['json_data']
    todos.create_task(tasks, name, description=description, due_on=due_on)

    serialized = todos.serialize(tasks)
    with open(ctx.obj['data_file_path'], 'w') as fp:
        fp.write(_json_dumps(serialized))
Пример #3
0
def test_create_new_task_basic():
    tasks = todos.new()
    todos.create_task(tasks, 'Email team updates')

    assert tasks == [{
        'task': 'Email team updates',
        'description': None,
        'due_on': None,
        'status': 'pending'
    }]
Пример #4
0
def test_create_new_task_invalid_due_date():
    """
    If the date passed is invalid it should raise an:
        `InvalidTaskDueDateException`
    """
    tasks = todos.new()

    with pytest.raises(InvalidTaskDueDateException):
        todos.create_task(
            tasks, 'Email team updates',
            description='Some more details',
            due_on='not-a-datetime-object')
Пример #5
0
def test_create_new_task_with_description():
    tasks = todos.new()

    todos.create_task(
        tasks, 'Email team updates',
        description='Some more details')

    assert tasks == [{
        'task': 'Email team updates',
        'description': 'Some more details',
        'due_on': None,
        'status': 'pending'
    }]
Пример #6
0
def test_create_new_task_due_date_string_date():
    tasks = todos.new()

    todos.create_task(
        tasks, 'Email team updates',
        description='Some more details',
        due_on='2018-03-01')

    assert tasks == [{
        'task': 'Email team updates',
        'description': 'Some more details',
        'due_on': datetime(2018, 3, 1),  # datetime object automatically added
        'status': 'pending'
    }]
Пример #7
0
def test_create_new_task_with_description_and_due_date():
    tasks = todos.new()

    todos.create_task(
        tasks, 'Email team updates',
        description='Some more details',
        due_on=datetime(2018, 3, 1, 9))

    assert tasks == [{
        'task': 'Email team updates',
        'description': 'Some more details',
        'due_on': datetime(2018, 3, 1, 9),
        'status': 'pending'
    }]
Пример #8
0
import todos

from pprint import pprint

with open('sample_todos.json', 'r') as fp:
    tasks = todos.unserialize(fp.read())

# List tasks

task_list = todos.list_tasks(tasks)
pprint(task_list)

# Create task
"""
todos.create_task(tasks, 'Take out the trash')
pprint(tasks)
"""
# Complete task
"""
new_tasks = todos.complete_task(tasks, 'Review AWS proposal')
pprint(new_tasks)
"""