Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
f7ce0019
Unverified
Commit
f7ce0019
authored
5 years ago
by
Daniel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Test for duplicate parents. Also refactored.
parent
2b67fcdd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_issues_mysqlbackend.py
+13
-43
13 additions, 43 deletions
tests/test_issues_mysqlbackend.py
tests/test_issues_server.py
+93
-0
93 additions, 0 deletions
tests/test_issues_server.py
with
106 additions
and
43 deletions
tests/test_issues_mysqlbackend.py
+
13
−
43
View file @
f7ce0019
...
...
@@ -23,20 +23,12 @@
"""
Tests for issues on gitlab.com, project caosdb-mysqlbackend.
"""
from
__future__
import
absolute_import
,
print_function
,
unicode_literals
import
caosdb
as
db
from
caosdb.exceptions
import
(
AmbiguityException
,
CaosDBException
,
EntityDoesNotExistError
,
EntityError
,
TransactionError
,
UniqueNamesError
)
from
nose
import
with_setup
from
nose.tools
import
(
assert_equal
,
assert_false
,
assert_is_none
,
assert_is_not_none
,
assert_raises
,
assert_true
,
nottest
)
from
nose.tools
import
assert_equal
import
numpy
as
np
import
pytest
# from tests import test_misc
def
setup_module
():
try
:
...
...
@@ -47,7 +39,7 @@ def setup_module():
def
setup
():
"""
No setup required.
"""
pass
setup_module
()
def
teardown
():
...
...
@@ -57,48 +49,26 @@ def teardown():
# ########################### Issue tests start here ###########################
@pytest.mark.xfail
@with_setup
(
setup
,
teardown
)
def
test_issue_8
5_a
():
"""
S
QLIntegrityConstraintViolationException for special inheritance patterns
.
def
test_issue_
1
8
():
"""
S
ometimes, duplicate parents were returned
.
Tests for https://gitlab.com/caosdb/caosdb-
server
/-/issues/8
5
Tests for https://gitlab.com/caosdb/caosdb-
mysqlbackend
/-/issues/
1
8
"""
A
=
db
.
RecordType
(
name
=
"
A
"
)
B
=
db
.
RecordType
(
name
=
"
B
"
)
C
=
db
.
RecordType
(
name
=
"
C
"
)
B
.
add_parent
(
A
)
# This order is important for the test to fail.
C
.
add_parent
(
B
)
C
.
add_parent
(
C
)
C
.
add_parent
(
C
)
# The self-parenting is here on purpose
C
.
add_parent
(
A
)
c
=
db
.
Container
()
# c.extend([C, B, A]) # worked before #86 was fixed
# c.extend([C, A, B]) # worked before #86 was fixed
c
.
extend
([
B
,
C
,
A
])
# insert() failed before #86 was fixed
c
.
insert
()
# Raised java.sql.SQLIntegrityConstraintViolationException:
# # Duplicate entry '12345-12346-12345' for key 'PRIMARY'
@with_setup
(
setup
,
teardown
)
def
test_issue_85_b
():
"""
SQLIntegrityConstraintViolationException for special inheritance patterns.
c
.
extend
([
B
,
C
,
A
])
c
.
insert
()
Tests for https://gitlab.com/caosdb/caosdb-server/-/issues/85
"""
A
=
db
.
RecordType
(
name
=
"
A
"
)
B
=
db
.
RecordType
(
name
=
"
B
"
)
C
=
db
.
RecordType
(
name
=
"
C
"
)
A
.
insert
()
B
.
insert
()
C
.
insert
()
B
.
add_parent
(
A
)
B
.
update
()
C
.
add_parent
(
B
)
C
.
update
()
C
.
add_parent
(
C
)
C
.
update
()
C
.
add_parent
(
A
)
C
.
update
()
# Failed at this step
C1
=
db
.
Entity
(
name
=
"
C
"
).
retrieve
()
pids
=
[
p
.
id
for
p
in
C1
.
parents
]
assert_equal
(
np
.
unique
(
pids
),
len
(
pids
),
"
Duplicate parents.
"
)
This diff is collapsed.
Click to expand it.
tests/test_issues_server.py
0 → 100644
+
93
−
0
View file @
f7ce0019
# -*- coding: utf-8 -*-
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (c) 2020 IndiScale GmbH (www.indiscale.com)
# Copyright (c) 2020 Daniel Hornung (d.hornung@indiscale.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
"""
Tests for issues on gitlab.com, project caosdb-mysqlbackend.
"""
import
caosdb
as
db
from
nose
import
with_setup
def
setup_module
():
try
:
db
.
execute_query
(
"
FIND ENTITY WITH ID > 100
"
).
delete
()
except
Exception
as
delete_exc
:
print
(
delete_exc
)
def
setup
():
"""
No setup required.
"""
setup_module
()
def
teardown
():
"""
Deleting entities again.
"""
setup_module
()
# ########################### Issue tests start here ###########################
@with_setup
(
setup
,
teardown
)
def
test_issue_85_a
():
"""
SQLIntegrityConstraintViolationException for special inheritance patterns.
Tests for https://gitlab.com/caosdb/caosdb-server/-/issues/85
"""
A
=
db
.
RecordType
(
name
=
"
A
"
)
B
=
db
.
RecordType
(
name
=
"
B
"
)
C
=
db
.
RecordType
(
name
=
"
C
"
)
B
.
add_parent
(
A
)
# This order is important for the test to fail.
C
.
add_parent
(
B
)
C
.
add_parent
(
C
)
C
.
add_parent
(
A
)
c
=
db
.
Container
()
# c.extend([C, B, A]) # worked before #86 was fixed
# c.extend([C, A, B]) # worked before #86 was fixed
c
.
extend
([
B
,
C
,
A
])
# insert() failed before #86 was fixed
c
.
insert
()
# Raised java.sql.SQLIntegrityConstraintViolationException:
# # Duplicate entry '12345-12346-12345' for key 'PRIMARY'
@with_setup
(
setup
,
teardown
)
def
test_issue_85_b
():
"""
SQLIntegrityConstraintViolationException for special inheritance patterns.
Tests for https://gitlab.com/caosdb/caosdb-server/-/issues/85
"""
A
=
db
.
RecordType
(
name
=
"
A
"
)
B
=
db
.
RecordType
(
name
=
"
B
"
)
C
=
db
.
RecordType
(
name
=
"
C
"
)
A
.
insert
()
B
.
insert
()
C
.
insert
()
B
.
add_parent
(
A
)
B
.
update
()
C
.
add_parent
(
B
)
C
.
update
()
C
.
add_parent
(
C
)
C
.
update
()
C
.
add_parent
(
A
)
C
.
update
()
# Failed at this step
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment