-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathconftest.py
More file actions
executable file
·64 lines (49 loc) · 1.63 KB
/
conftest.py
File metadata and controls
executable file
·64 lines (49 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Define some fixtures to use in the project."""
import pytest
import tasks
from tasks import Task
@pytest.fixture()
def tasks_db(tmpdir):
"""Connect to db before tests, disconnect after."""
# Setup : start db
tasks.start_tasks_db(str(tmpdir), "tiny")
yield # this is where the testing happens
# Teardown : stop db
tasks.stop_tasks_db()
# Reminder of Task constructor interface
# Task(summary=None, owner=None, done=False, id=None)
# summary is required
# owner and done are optional
# id is set by database
@pytest.fixture()
def tasks_just_a_few():
"""All summaries and owners are unique."""
return (
Task("Write some code", "Brian", True),
Task("Code review Brian's code", "Katie", False),
Task("Fix what Brian did", "Michelle", False),
)
@pytest.fixture()
def tasks_mult_per_owner():
"""Several owners with several tasks each."""
return (
Task("Make a cookie", "Raphael"),
Task("Use an emoji", "Raphael"),
Task("Move to Berlin", "Raphael"),
Task("Create", "Michelle"),
Task("Inspire", "Michelle"),
Task("Encourage", "Michelle"),
Task("Do a handstand", "Daniel"),
Task("Write some books", "Daniel"),
Task("Eat ice cream", "Daniel"),
)
@pytest.fixture()
def db_with_3_tasks(tasks_db, tasks_just_a_few):
"""Connected db with 3 tasks, all unique."""
for t in tasks_just_a_few:
tasks.add(t)
@pytest.fixture()
def db_with_multi_per_owner(tasks_db, tasks_mult_per_owner):
"""Connected db with 9 tasks, 3 owners, all with 3 tasks."""
for t in tasks_mult_per_owner:
tasks.add(t)