Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Commit e408c91

Browse files
author
platipusica
committed
latest tests
1 parent 11c08bc commit e408c91

File tree

6 files changed

+235
-30
lines changed

6 files changed

+235
-30
lines changed

tests/__test_edit_lock.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import pytest
2+
3+
@pytest.fixture
4+
def master(task):
5+
master = task.master.copy()
6+
master.empty()
7+
detail1 = task.detail1.copy()
8+
detail1.empty()
9+
master.open()
10+
for i in range(2):
11+
master.append()
12+
master.val.value = i
13+
master.detail1.open()
14+
for j in range(2):
15+
master.detail1.append()
16+
master.detail1.val.value = j
17+
master.detail1.post()
18+
master.post()
19+
master.apply()
20+
return task.master.copy()
21+
22+
class TestEditLock:
23+
24+
def test_copy_edit_lock(self, master):
25+
master.edit_lock = False
26+
copy = master.copy()
27+
assert not copy.edit_lock
28+
29+
master.edit_lock = True
30+
copy = master.copy()
31+
assert copy.edit_lock
32+
33+
def test_detail_copy_edit_lock(self, master):
34+
master.detail1.edit_lock = False
35+
copy = master.copy()
36+
assert not copy.detail1.edit_lock
37+
38+
master.detail1.edit_lock = True
39+
copy = master.copy()
40+
assert copy.detail1.edit_lock
41+
42+
@pytest.mark.parametrize(('master_rec_no, copy_rec_no, master_edit_lock, copy_edit_lock'), [
43+
(0, 0, True, True),
44+
(0, 1, True, True),
45+
(0, 0, True, False),
46+
(0, 0, False, True)
47+
])
48+
49+
def test_edit_lock(self, master, master_rec_no, copy_rec_no, master_edit_lock, copy_edit_lock):
50+
copy = master.copy()
51+
52+
master.edit_lock = master_edit_lock
53+
copy.edit_lock = copy_edit_lock
54+
55+
master.open()
56+
copy.open()
57+
58+
assert master.rec_count == 2
59+
assert copy.rec_count == 2
60+
61+
master.rec_no = master_rec_no
62+
copy.rec_no = copy_rec_no
63+
64+
master.edit()
65+
master.val.value += 1
66+
master.post()
67+
copy.edit()
68+
copy.val.value += 1
69+
copy.post()
70+
master.apply()
71+
if master_rec_no == copy_rec_no and master_edit_lock and master_edit_lock == copy_edit_lock:
72+
with pytest.raises(Exception):
73+
copy.apply()
74+
else:
75+
copy.apply()
76+
77+
@pytest.mark.parametrize(('master_rec_no, copy_rec_no, master_edit_lock, copy_edit_lock'), [
78+
(0, 0, True, True),
79+
(0, 1, True, True),
80+
(0, 0, True, False),
81+
(0, 0, False, True)
82+
])
83+
84+
def test_detail_edit_lock(self, master, master_rec_no, copy_rec_no, master_edit_lock, copy_edit_lock):
85+
copy = master.copy()
86+
87+
master.edit_lock = False
88+
copy.edit_lock = False
89+
90+
master.detail1.edit_lock = master_edit_lock
91+
copy.detail1.edit_lock = copy_edit_lock
92+
93+
master.open()
94+
master.detail1.open()
95+
copy.open()
96+
copy.detail1.open()
97+
98+
master.detail1.rec_no = master_rec_no
99+
copy.detail1.rec_no = copy_rec_no
100+
101+
master.edit()
102+
master.detail1.edit()
103+
master.detail1.val.value += 1
104+
master.detail1.post()
105+
master.post()
106+
copy.edit()
107+
copy.detail1.edit()
108+
copy.detail1.val.value += 1
109+
copy.detail1.post()
110+
copy.post()
111+
master.apply()
112+
if master_rec_no == copy_rec_no and master_edit_lock and master_edit_lock == copy_edit_lock:
113+
with pytest.raises(Exception):
114+
copy.apply()
115+
else:
116+
copy.apply()
117+

tests/project/admin.sqlite

6 KB
Binary file not shown.

tests/project/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
</head>
88
<body>
99
<div id="mocha"></div>
10-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/6.1.4/mocha.js"></script>
11-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
12-
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/11.7.2/mocha.js" integrity="sha512-fkbbLwJa63/3v5t/mpAjyZgDtTTO/3eiTp5ezwQqCvInGu0pCS5rW3HUx+dUKw6mkoP48/lbu5g5hGAY809p9w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
11+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/chai.js"></script>
1312
<script>mocha.setup('bdd')</script>
1413
<script src="jam/js/jquery.js"></script>
1514
<script src="jam/js/bs5/bootstrap.bundle.js"></script>
16-
<!--<script src="jam/js/bootstrap-datepicker.js"></script>-->
1715
<script src="jam/js/zebra_datepicker.js"></script>
1816
<script src="jam/js/jquery.maskedinput.js"></script>
1917
<script type="module" src="jam/js/jam.js"></script>

0 commit comments

Comments
 (0)