-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_transactions.py
58 lines (37 loc) · 1.22 KB
/
test_transactions.py
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
import pytest
from test_django_plugin.app.models import Author, Book
@pytest.fixture(scope='module')
def lem(module_transaction):
with module_transaction('lem'):
yield Author.objects.create(first_name='Stanislav', last_name='Lem')
@pytest.fixture
def solaris(function_fixture, lem):
yield Book.objects.create(name='Solaris', year=1961, author=lem)
def test_00():
assert Author.objects.count() == 0
assert Book.objects.count() == 0
author_id = None
book_id = None
def test_01(solaris, lem):
global author_id, book_id
assert Author.objects.count() == 1
assert Book.objects.count() == 1
author_id = id(lem)
book_id = id(solaris)
def test_02(solaris, lem):
assert id(lem) == author_id
assert id(solaris) != book_id
assert Author.objects.count() == 1
assert Book.objects.count() == 1
def test_03():
assert Author.objects.count() == 0
assert Book.objects.count() == 0
def test_04(solaris, lem):
assert Author.objects.count() == 1
assert Book.objects.count() == 1
def test_05():
assert Author.objects.count() == 0
assert Book.objects.count() == 0
def test_06(solaris, lem):
assert Author.objects.count() == 1
assert Book.objects.count() == 1