-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathtest_unique_id_4.py
More file actions
executable file
·49 lines (38 loc) · 1.15 KB
/
test_unique_id_4.py
File metadata and controls
executable file
·49 lines (38 loc) · 1.15 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
"""Test tasks.unique_id()."""
import pytest
import tasks
from tasks import Task
@pytest.mark.xfail(
tasks.__version__ < "0.2.0", reason="not supported until version 0.2.0"
)
def test_unique_id_1():
"""Calling unique_id() twice should return different numbers."""
id_1 = tasks.unique_id()
id_2 = tasks.unique_id()
assert id_1 != id_2
@pytest.mark.xfail()
def test_unique_id_is_a_duck():
"""Demonstrate xfail."""
uid = tasks.unique_id()
assert uid == "a duck"
@pytest.mark.xfail()
def test_unique_id_not_a_duck():
"""Demonstrate xpass."""
uid = tasks.unique_id()
assert uid != "a duck"
def test_unique_id_2():
"""unique_id() should return an unused id."""
ids = []
ids.append(tasks.add(Task("one")))
ids.append(tasks.add(Task("two")))
ids.append(tasks.add(Task("three")))
# grab a unique id
uid = tasks.unique_id()
# make sure it isn't in the list of existing ids
assert uid not in ids
@pytest.fixture(autouse=True)
def initialized_tasks_db(tmpdir):
"""Connect to db before testing, disconnect after."""
tasks.start_tasks_db(str(tmpdir), "tiny")
yield
tasks.stop_tasks_db()