def test_added_task_has_id_set(tasks_db): """Make sure the task_id field is set by tasks.add().""" # GIVEN an initialized tasks db # AND a new task is added new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # WHEN task is retrieved task_from_db = tasks.get(task_id) # THEN task_id matches id field assert task_from_db.id == task_id # AND contents are equivalent (except for id) # the [:-1] syntax returns a list with all but the last element assert task_from_db[:-1] == new_task[:-1]
def test_get_raises(): """get() should raise an exception with wrong type param.""" with pytest.raises(TypeError): tasks.get(task_id='123')
def test_add_c(tasks_db, c_task): """Use fixture with generated ids.""" task_id = tasks.add(c_task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, c_task)
def test_add_b(tasks_db, b_task): """Using b_task fixture, with ids.""" task_id = tasks.add(b_task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, b_task)
def test_add_a(tasks_db, a_task): """Using a_task fixture (no ids).""" task_id = tasks.add(a_task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, a_task)