FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
datajoint-python/tests/test_cascading_delete.py at master · colima/datajoint-python · GitHub
colima
datajoint-python
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
datajoint-python
/
tests
/
test_cascading_delete.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
82 lines (74 loc) · 3.11 KB
Breadcrumbs
datajoint-python
/
tests
/
test_cascading_delete.py
Copy path
File metadata and controls
82 lines (74 loc) · 3.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from
nose
.
tools
import
assert_false
,
assert_true
import
datajoint
as
dj
from
.
schema_simple
import
A
,
B
,
D
,
E
,
L
class
TestDelete
:
@
staticmethod
def
setup
():
"""
class-level test setup. Executes before each test method.
"""
A
().
insert
(
A
.
contents
,
skip_duplicates
=
True
)
L
().
insert
(
L
.
contents
,
skip_duplicates
=
True
)
B
().
populate
()
D
().
populate
()
E
().
populate
()
@
staticmethod
def
test_delete_tree
():
assert_false
(
dj
.
config
[
'safemode'
],
'safemode must be off for testing'
)
assert_true
(
L
()
and
A
()
and
B
()
and
B
.
C
()
and
D
()
and
E
()
and
E
.
F
(),
'schema is not populated'
)
A
().
delete
()
assert_false
(
A
()
or
B
()
or
B
.
C
()
or
D
()
or
E
()
or
E
.
F
(),
'incomplete delete'
)
@
staticmethod
def
test_stepwise_delete
():
assert_false
(
dj
.
config
[
'safemode'
],
'safemode must be off for testing'
)
#TODO: just turn it off instead of warning
assert_true
(
L
()
and
A
()
and
B
()
and
B
.
C
(),
'schema population failed as a precondition to test'
)
B
.
C
().
delete
()
assert_false
(
B
.
C
(),
'failed to delete child tables'
)
B
().
delete
()
assert_false
(
B
(),
'failed to delete the parent table following child table deletion'
)
@
staticmethod
def
test_delete_tree_restricted
():
assert_false
(
dj
.
config
[
'safemode'
],
'safemode must be off for testing'
)
assert_true
(
L
()
and
A
()
and
B
()
and
B
.
C
()
and
D
()
and
E
()
and
E
.
F
(),
'schema is not populated'
)
cond
=
'cond_in_a'
rel
=
A
()
&
cond
rest
=
dict
(
A
=
len
(
A
())
-
len
(
rel
),
B
=
len
(
B
()
-
rel
),
C
=
len
(
B
.
C
()
-
rel
),
D
=
len
(
D
()
-
rel
),
E
=
len
(
E
()
-
rel
),
F
=
len
(
E
.
F
()
-
rel
))
rel
.
delete
()
assert_false
(
rel
or
(
B
()
&
rel
)
or
(
B
.
C
()
&
rel
)
or
(
D
()
&
rel
)
or
(
E
()
&
rel
)
or
(
E
.
F
()
&
rel
),
'incomplete delete'
)
assert_true
(
len
(
A
())
==
rest
[
'A'
]
and
len
(
B
())
==
rest
[
'B'
]
and
len
(
B
.
C
())
==
rest
[
'C'
]
and
len
(
D
())
==
rest
[
'D'
]
and
len
(
E
())
==
rest
[
'E'
]
and
len
(
E
.
F
())
==
rest
[
'F'
],
'incorrect restricted delete'
)
@
staticmethod
def
test_delete_lookup
():
assert_false
(
dj
.
config
[
'safemode'
],
'safemode must be off for testing'
)
assert_true
(
bool
(
L
()
and
A
()
and
B
()
and
B
.
C
()
and
D
()
and
E
()
and
E
.
F
()),
'schema is not populated'
)
L
().
delete
()
assert_false
(
bool
(
L
()
or
D
()
or
E
()
or
E
.
F
()),
'incomplete delete'
)
A
().
delete
()
# delete all is necessary because delete L deletes from subtables.
@
staticmethod
def
test_delete_lookup_restricted
():
assert_false
(
dj
.
config
[
'safemode'
],
'safemode must be off for testing'
)
assert_true
(
L
()
and
A
()
and
B
()
and
B
.
C
()
and
D
()
and
E
()
and
E
.
F
(),
'schema is not populated'
)
rel
=
L
()
&
'cond_in_l'
original_count
=
len
(
L
())
deleted_count
=
len
(
rel
)
rel
.
delete
()
assert_true
(
len
(
L
())
==
original_count
-
deleted_count
)
Back
|
FazBrowse Home
|
New Git URL