Ejemplo n.º 1
0
def test_create_new_todo_with_existing_todos(todos_with_categories):
    manager = TodoManager(TESTING_PATH)
    manager.new(
        'New Testing Task',
        category='programming',
        description='A new task to test...',
        due_on=date(2018, 3, 1))

    general_todos_path = todos_with_categories / 'programming.json'

    assert general_todos_path.exists()
    with general_todos_path.open('r') as fp:
        todos = json.load(fp)

    assert todos == {
        'category_name': 'Programming',
        'todos': [{
            'task': 'Practice Pathlib',
            'description': 'Investigate Pathlib and file creation',
            'due_on': '2018-03-25',
            'status': 'pending'
        }, {
            'task': 'Finish rmotrgram',
            'description': 'Finish before class to start reviewing',
            'due_on': '2018-03-21',
            'status': 'done'
        }, {  # New todo:
            'task': 'New Testing Task',
            'description': 'A new task to test...',
            'due_on': '2018-03-01',
            'status': 'pending'
        }]
    }
Ejemplo n.º 2
0
def test_mark_todo_as_complete(todos_with_categories):
    manager = TodoManager(TESTING_PATH)
    manager.complete('Practice Pathlib', category='programming')

    general_todos_path = todos_with_categories / 'programming.json'

    assert general_todos_path.exists()
    with general_todos_path.open('r') as fp:
        todos = json.load(fp)

    assert todos == {
        'category_name':
        'Programming',
        'todos': [
            {
                'task': 'Practice Pathlib',
                'description': 'Investigate Pathlib and file creation',
                'due_on': '2018-03-25',
                'status':
                'done'  # Status should be changed from pending to done
            },
            {
                'task': 'Finish rmotrgram',
                'description': 'Finish before class to start reviewing',
                'due_on': '2018-03-21',
                'status': 'done'
            }
        ]
    }
def test_todo_list_status_done(todos_with_categories):
    manager = TodoManager(TESTING_PATH)
    todos = manager.list(status=TodoManager.STATUS_DONE)
    assert todos == {
        'Programming': [{
            'task': 'Finish rmotrgram',
            'description': 'Finish before class to start reviewing',
            'due_on': '2018-03-21',
            'status': 'done'
        }],
        'Reviews': []
    }
def test_todo_list_status_pending(todos_with_categories):
    manager = TodoManager(TESTING_PATH)
    todos = manager.list(status=TodoManager.STATUS_PENDING)
    assert todos == {
        'Programming': [{
            'task': 'Practice Pathlib',
            'description': 'Investigate Pathlib and file creation',
            'due_on': '2018-03-25',
            'status': 'pending'
        }],
        'Reviews': [{
            'task': 'Review rmotrgram',
            'description': 'Finish review before weekend',
            'due_on': '2018-03-28',
            'status': 'pending'
        }]
    }
def test_todos_dir_is_created(path):
    assert not path.exists()

    manager = TodoManager(TESTING_PATH)
    assert path.exists()
    assert path.is_dir()

    # Clean up
    shutil.rmtree(str(path.absolute()))
Ejemplo n.º 6
0
def test_create_new_todo_general_empty_dir_default_vals(todos_dir_empty):
    manager = TodoManager(TESTING_PATH)
    manager.new('New Testing Task')

    general_todos_path = todos_dir_empty / 'general.json'

    assert general_todos_path.exists()
    with general_todos_path.open('r') as fp:
        todos = json.load(fp)

    assert todos == {
        'category_name': 'General',
        'todos': [{
            'task': 'New Testing Task',
            'description': None,
            'due_on': None,
            'status': 'pending'
        }]
    }
def test_create_new_todo_general_empty_dir_due_date(todos_dir_empty):
    manager = TodoManager(TESTING_PATH)
    manager.new('New Testing Task',
                description='A new task to test...',
                due_on=date(2018, 3, 1))

    general_todos_path = todos_dir_empty / 'general.json'

    assert general_todos_path.exists()
    with general_todos_path.open('r') as fp:
        todos = json.load(fp)

    assert todos == {
        'category_name':
        'General',
        'todos': [{
            'task': 'New Testing Task',
            'description': 'A new task to test...',
            'due_on': '2018-03-01',
            'status': 'pending'
        }]
    }
Ejemplo n.º 8
0
def cli(ctx, debug, indent, path):
    ctx.obj['debug'] = debug
    ctx.obj['indent'] = indent
    ctx.obj['path'] = path
    ctx.obj['manager'] = TodoManager(path)
    _debug('Debug mode is %s' % ('on' if debug else 'off'))