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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
1fdb11de
Commit
1fdb11de
authored
4 years ago
by
Timm Fitschen
Committed by
Quazgar
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
TST: Tests for version history
parent
71ea04ff
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
tests/test_misc.py
+0
-12
0 additions, 12 deletions
tests/test_misc.py
tests/test_permissions.py
+7
-6
7 additions, 6 deletions
tests/test_permissions.py
tests/test_version.py
+36
-8
36 additions, 8 deletions
tests/test_version.py
with
44 additions
and
26 deletions
CHANGELOG.md
+
1
−
0
View file @
1fdb11de
...
...
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added (for new features)
*
Tests for version history
*
Tests for inheritance bug (caosdb/caosdb-server!54)
*
Tests for versioning
*
Tests for deeply nested SELECT queries
...
...
This diff is collapsed.
Click to expand it.
tests/test_misc.py
+
0
−
12
View file @
1fdb11de
...
...
@@ -262,18 +262,6 @@ def test_annotation():
rt
=
execute_query
(
"
FIND AnnotationTest*
"
).
delete
()
def
test_history
():
try
:
rt
=
RecordType
(
name
=
"
SimpleTestProperty
"
).
insert
()
rt
.
retrieve
(
flags
=
{
"
H
"
:
None
})
assert_equal
(
rt
.
messages
[
"
History
"
],
(
'
Insert
'
,
None
))
finally
:
try
:
rt
.
delete
()
except
BaseException
:
pass
def
test_info
():
i
=
Info
()
assert_is_not_none
(
i
.
messages
[
"
Flags
"
])
...
...
This diff is collapsed.
Click to expand it.
tests/test_permissions.py
+
7
−
6
View file @
1fdb11de
...
...
@@ -937,25 +937,26 @@ def test_retrieve_acl():
assert_equal
(
e
.
msg
,
"
You are not allowed to do this.
"
)
@with_setup
(
setup
,
teardown
)
def
test_retrieve_history
():
p
=
db
.
Property
(
name
=
"
TestProperty
"
,
datatype
=
db
.
TEXT
).
insert
()
assert_true
(
p
.
is_valid
())
grant_permission
(
p
,
"
RETRIEVE:ENTITY
"
)
p
.
retrieve
()
assert
p
.
version
is
not
None
assert
p
.
version
.
username
is
None
,
"
username belongs to history
"
'''
Failure
'''
try
:
with
raises
(
db
.
TransactionError
)
as
exc
:
p
.
retrieve
(
flags
=
{
"
H
"
:
None
})
assert_true
(
False
)
except
db
.
TransactionError
as
e
:
assert_equal
(
e
.
msg
,
"
You are not allowed to do this.
"
)
assert
"
You are not allowed to do this.
"
in
str
(
exc
.
value
)
'''
Success
'''
grant_permission
(
p
,
"
RETRIEVE:HISTORY
"
)
p
.
retrieve
(
flags
=
{
"
H
"
:
None
})
assert_equal
(
p
.
messages
[
"
History
"
],
(
'
Insert
'
,
None
))
assert
p
.
version
is
not
None
assert
p
.
version
.
username
==
db
.
get_config
().
get
(
"
Connection
"
,
"
username
"
)
@with_setup
(
setup
,
teardown
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_version.py
+
36
−
8
View file @
1fdb11de
...
...
@@ -47,7 +47,7 @@ def insertion(name="TestRT", parents=[]):
rt
.
insert
()
assert
rt
.
version
is
not
None
assert
rt
.
version
.
id
is
not
None
assert
rt
.
version
.
date
is
not
Non
e
assert
rt
.
version
.
is_head
is
Tru
e
assert
len
(
rt
.
version
.
predecessors
)
==
0
assert
len
(
rt
.
version
.
successors
)
==
0
return
rt
...
...
@@ -58,7 +58,6 @@ def test_retrieve():
version
=
rt
.
version
rt2
=
c
.
execute_query
(
"
FIND RecordType TestRT
"
,
unique
=
True
)
assert
parse
(
rt2
.
version
.
date
)
==
parse
(
version
.
date
)
assert
rt2
.
version
==
version
...
...
@@ -72,10 +71,8 @@ def test_update_description():
assert
rt
.
description
==
new_desc
assert
rt
.
version
is
not
None
assert
rt
.
version
.
id
is
not
None
assert
rt
.
version
.
date
is
not
None
assert
rt
.
version
!=
old_version
assert
rt
.
version
.
date
!=
old_version
.
date
assert
parse
(
rt
.
version
.
date
)
>
parse
(
old_version
.
date
)
assert
rt
.
version
.
is_head
is
True
rt2
=
c
.
execute_query
(
"
FIND RecordType TestRT
"
,
unique
=
True
)
assert
rt2
.
version
.
id
==
rt
.
version
.
id
...
...
@@ -92,6 +89,7 @@ def test_update_description():
"
@
"
+
old_version
.
id
,
sync
=
False
)[
0
]
assert
rt_old
.
version
.
id
==
old_version
.
id
assert
rt_old
.
description
==
old_desc
assert
rt_old
.
version
.
is_head
is
False
def
test_update_parent
():
...
...
@@ -740,10 +738,7 @@ def test_update_name():
assert
rt
.
name
==
new_name
assert
rt
.
version
is
not
None
assert
rt
.
version
.
id
is
not
None
assert
rt
.
version
.
date
is
not
None
assert
rt
.
version
!=
old_version
assert
rt
.
version
.
date
!=
old_version
.
date
assert
parse
(
rt
.
version
.
date
)
>
parse
(
old_version
.
date
)
assert
len
(
c
.
execute_query
(
"
FIND RecordType {}
"
.
format
(
old_name
)))
==
0
rt2
=
c
.
execute_query
(
"
FIND RecordType {}
"
.
format
(
new_name
),
unique
=
True
)
...
...
@@ -819,3 +814,36 @@ def test_delete_referenced_entity():
rec_v2
=
c
.
Container
().
retrieve
(
query
=
str
(
rec
.
id
)
+
"
@HEAD
"
,
flags
=
{
"
cache
"
:
"
false
"
},
sync
=
False
)[
0
]
assert
rec_v2
.
get_property
(
ref_rt
)
is
None
def
test_retrieve_history
():
rt
=
insertion
()
versions
=
[]
desc
=
dict
()
versions
.
append
(
rt
.
version
)
desc
[
rt
.
version
.
id
]
=
rt
.
description
v5_version
=
None
for
i
in
range
(
10
):
rt
.
description
=
rt
.
description
+
str
(
i
)
rt
.
update
()
versions
.
append
(
rt
.
version
)
desc
[
rt
.
version
.
id
]
=
rt
.
description
if
i
==
5
:
v5_version
=
rt
.
version
# retrieve history
rt_v5
=
c
.
Container
().
retrieve
(
query
=
str
(
rt
.
id
)
+
"
@HEAD~4
"
,
flags
=
{
"
H
"
:
None
},
sync
=
False
)[
0
]
assert
rt_v5
.
version
.
is_complete_history
is
True
assert
rt_v5
.
version
.
id
==
v5_version
.
id
history
=
rt_v5
.
version
.
get_history
()
assert
len
(
history
)
==
len
(
versions
)
# Compare actual and expected version
for
act
,
exp
in
zip
(
history
,
versions
):
assert
act
.
id
==
exp
.
id
tst
=
c
.
Container
().
retrieve
(
query
=
str
(
rt
.
id
)
+
"
@
"
+
act
.
id
,
sync
=
False
)[
0
]
assert
tst
.
description
==
desc
[
act
.
id
]
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