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' }] }
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' }] }