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
4ae481ce
Verified
Commit
4ae481ce
authored
1 month ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
REFACTOR: LinkAhead renaming.
parent
6f4a8376
No related branches found
No related tags found
1 merge request
!91
Remove dropoffbox
Pipeline
#62701
passed
4 weeks ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_tenpoints.py
+86
-82
86 additions, 82 deletions
tests/test_tenpoints.py
with
86 additions
and
82 deletions
tests/test_tenpoints.py
+
86
−
82
View file @
4ae481ce
# -*- coding: utf-8 -*-
#
# ** header v3.0
# This file is a part of the
CaosDB
Project.
# This file is a part of the
LinkAhead
Project.
#
# Copyright (C) 2024 Daniel Hornung
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2024 IndiScale GmbH
# Copyright (C) 2024 Daniel Hornung
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
...
...
@@ -27,9 +27,9 @@
@author: fitschen
"""
import
caosdb
as
h
import
linkahead
as
db
import
os
from
caosdb
.exceptions
import
CaosDB
Exception
from
linkahead
.exceptions
import
LinkAhead
Exception
'''
1) Struktur:
...
...
@@ -55,7 +55,7 @@ Description oder einer Zahl'''
def
setup_function
(
function
):
try
:
h
.
execute_query
(
"
FIND ENTITY *
"
).
delete
()
db
.
execute_query
(
"
FIND ENTITY *
"
).
delete
()
except
Exception
as
e
:
print
(
e
)
...
...
@@ -70,30 +70,30 @@ def test_tenpoints1_1():
enthalten (Gewicht, Beschreibung, Identifkationsnummern, etc.)
'''
c
=
h
.
Container
()
c
=
db
.
Container
()
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDoubleProperty
"
,
description
=
"
simple double property (from test_tenpoints.py)
"
,
datatype
=
'
double
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_tenpoints.py)
"
,
datatype
=
'
integer
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_tenpoints.py)
"
,
datatype
=
'
datetime
'
))
c
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
SimpleRecordType
"
,
description
=
"
simple recordType (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
SimpleTextProperty
'
)
.
add_property
(
...
...
@@ -108,35 +108,35 @@ def test_tenpoints1_2():
'''
1.2 Einfügen von RecordTypes, die zusätzlich Dateien referenzieren
'''
c
=
h
.
Container
()
c
=
db
.
Container
()
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDoubleProperty
"
,
description
=
"
simple double property (from test_tenpoints.py)
"
,
datatype
=
'
double
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_tenpoints.py)
"
,
datatype
=
'
integer
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_tenpoints.py)
"
,
datatype
=
'
datetime
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleFileProperty
"
,
description
=
"
simple file property (from test_tenpoints.py)
"
,
datatype
=
'
file
'
))
c
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
SimpleRecordType
"
,
description
=
"
simple recordType (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
SimpleTextProperty
'
)
.
add_property
(
...
...
@@ -154,35 +154,35 @@ def test_tenpoints1_3():
andere RecordTypes enthalten
'''
c
=
h
.
Container
()
c
=
db
.
Container
()
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDoubleProperty
"
,
description
=
"
simple double property (from test_tenpoints.py)
"
,
datatype
=
'
double
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_tenpoints.py)
"
,
datatype
=
'
integer
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_tenpoints.py)
"
,
datatype
=
'
datetime
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleFileProperty
"
,
description
=
"
simple file property (from test_tenpoints.py)
"
,
datatype
=
'
file
'
))
c
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
SimpleRecordType
"
,
description
=
"
simple recordType (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
SimpleTextProperty
'
)
.
add_property
(
...
...
@@ -192,11 +192,12 @@ def test_tenpoints1_3():
name
=
'
SimpleFileProperty
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
ReferenceProperty
"
,
description
=
'
reference property (from test_tenpoints.py)
'
,
datatype
=
"
SimpleRecordType
"
))
c
.
append
(
h
.
RecordType
(
name
=
"
ComlexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints.py)
"
)
c
.
append
(
db
.
RecordType
(
name
=
"
ComlexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints)
"
)
.
add_property
(
name
=
'
ReferenceProperty
'
)
# first method
# second method, doesn't need the ReferenceProperty
.
add_property
(
name
=
'
SimpleRecordType
'
)
...
...
@@ -220,37 +221,37 @@ def test_tenpoints1_5():
RecordTypes / Properties
'''
c
=
h
.
Container
()
c
=
db
.
Container
()
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDoubleProperty
"
,
description
=
"
simple double property (from test_tenpoints.py)
"
,
datatype
=
'
double
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_tenpoints.py)
"
,
datatype
=
'
integer
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_tenpoints.py)
"
,
datatype
=
'
datetime
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleFileProperty
"
,
description
=
"
simple file property (from test_tenpoints.py)
"
,
datatype
=
'
file
'
))
c
.
insert
()
d
=
h
.
Container
()
d
=
db
.
Container
()
d
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
SimpleRecordType
"
,
description
=
"
simple recordType (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
SimpleTextProperty
'
)
.
add_property
(
...
...
@@ -260,11 +261,11 @@ def test_tenpoints1_5():
name
=
'
SimpleFileProperty
'
))
d
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
ReferenceProperty
"
,
description
=
'
reference property (from test_tenpoints.py)
'
,
datatype
=
"
SimpleRecordType
"
))
d
.
append
(
h
.
RecordType
(
name
=
"
ComplexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints.py)
"
)
d
.
append
(
db
.
RecordType
(
name
=
"
ComplexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
ReferenceProperty
'
)
# first method
# second method, doesn't need the ReferenceProperty
.
add_property
(
name
=
'
SimpleRecordType
'
)
...
...
@@ -272,7 +273,7 @@ def test_tenpoints1_5():
d
.
insert
()
sr
=
(
h
.
Record
().
add_parent
(
name
=
"
SimpleRecordType
"
)
sr
=
(
db
.
Record
().
add_parent
(
name
=
"
SimpleRecordType
"
)
.
add_property
(
name
=
"
SimpleTextProperty
"
,
value
=
"
Some Text
"
)
.
add_property
(
name
=
"
SimpleDoubleProperty
"
,
value
=
3.14
)
.
add_property
(
name
=
"
SimpleIntegerProperty
"
,
value
=
1337
)
...
...
@@ -280,12 +281,12 @@ def test_tenpoints1_5():
sr
.
insert
()
cr1
=
(
h
.
Record
().
add_parent
(
name
=
"
ComplexRecordType
"
)
cr1
=
(
db
.
Record
().
add_parent
(
name
=
"
ComplexRecordType
"
)
.
add_property
(
name
=
"
ReferenceProperty
"
,
value
=
sr
))
cr1
.
insert
()
cr2
=
(
h
.
Record
().
add_parent
(
name
=
"
ComplexRecordType
"
)
cr2
=
(
db
.
Record
().
add_parent
(
name
=
"
ComplexRecordType
"
)
.
add_property
(
name
=
"
SimpleRecordType
"
,
value
=
sr
))
cr2
.
insert
()
...
...
@@ -299,36 +300,36 @@ def test_tenpoints2_1AND2_2():
'''
"""
data model.
"""
c
=
h
.
Container
()
c
=
db
.
Container
()
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDoubleProperty
"
,
description
=
"
simple double property (from test_tenpoints.py)
"
,
datatype
=
'
double
'
,
unit
=
"
m
"
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_tenpoints.py)
"
,
datatype
=
'
integer
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_tenpoints.py)
"
,
datatype
=
'
datetime
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleFileProperty
"
,
description
=
"
simple file property (from test_tenpoints.py)
"
,
datatype
=
'
file
'
))
c
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
SimpleRecordType
"
,
description
=
"
simple recordType (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
SimpleTextProperty
'
,
...
...
@@ -343,11 +344,12 @@ def test_tenpoints2_1AND2_2():
importance
=
'
obligatory
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
ReferenceProperty
"
,
description
=
'
reference property (from test_tenpoints.py)
'
,
datatype
=
"
SimpleRecordType
"
))
c
.
append
(
h
.
RecordType
(
name
=
"
ComplexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints.py)
"
)
c
.
append
(
db
.
RecordType
(
name
=
"
ComplexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints)
"
)
.
add_property
(
name
=
'
ReferenceProperty
'
)
# first method
# second method, doesn't need the ReferenceProperty
.
add_property
(
name
=
'
SimpleRecordType
'
)
...
...
@@ -357,7 +359,7 @@ def test_tenpoints2_1AND2_2():
print
(
c
)
'''
data
'''
d
=
h
.
Container
()
d
=
db
.
Container
()
'''
create testfile
'''
f
=
open
(
"
test.dat
"
,
"
w
"
)
...
...
@@ -366,7 +368,7 @@ def test_tenpoints2_1AND2_2():
'''
prepare file record
'''
d
.
append
(
h
.
File
(
db
.
File
(
id
=-
1
,
path
=
'
testfiles/testfile
'
,
file
=
"
test.dat
"
,
...
...
@@ -374,7 +376,7 @@ def test_tenpoints2_1AND2_2():
'''
prepare simple record with file property
'''
d
.
append
(
h
.
Record
(
db
.
Record
(
id
=-
2
,
name
=
"
SimpleRecord
"
)
.
add_parent
(
name
=
'
SimpleRecordType
'
)
.
add_property
(
...
...
@@ -389,7 +391,7 @@ def test_tenpoints2_1AND2_2():
name
=
'
SimpleFileProperty
'
,
value
=-
1
))
d
.
append
(
h
.
Record
()
d
.
append
(
db
.
Record
()
.
add_parent
(
name
=
"
ComplexRecordType
"
)
.
add_property
(
name
=
"
ReferenceProperty
"
,
value
=-
2
)
)
...
...
@@ -416,23 +418,23 @@ def test_tenpoints2_3():
'''
2.3 Verwendung von Einheiten
'''
"""
insert simple property with unit.
"""
p1
=
h
.
Property
(
name
=
'
unittestproperty
'
,
datatype
=
'
double
'
,
unit
=
'
m
'
)
p1
=
db
.
Property
(
name
=
'
unittestproperty
'
,
datatype
=
'
double
'
,
unit
=
'
m
'
)
p1
.
insert
()
'''
subtyping with unit inheritance
'''
p2
=
h
.
Property
(
name
=
'
SubTypeOfUnitTestProperty
'
).
add_parent
(
id
=
p1
.
id
)
p2
=
db
.
Property
(
name
=
'
SubTypeOfUnitTestProperty
'
).
add_parent
(
id
=
p1
.
id
)
p2
.
insert
()
assert
'
m
'
==
p2
.
unit
'''
implement property
'''
rt
=
h
.
RecordType
(
rt
=
db
.
RecordType
(
name
=
'
SimpleRecordType
'
,
description
=
'
simple recordType (from test_tenpoints.py)
'
).
add_property
(
id
=
p2
.
id
)
rt
.
insert
()
print
(
rt
)
rtid
=
rt
.
id
rt
=
h
.
RecordType
(
id
=
rtid
).
retrieve
()
rt
=
db
.
RecordType
(
id
=
rtid
).
retrieve
()
print
(
rt
)
assert
p2
.
id
==
rt
.
get_properties
()[
0
].
id
...
...
@@ -443,43 +445,43 @@ def test_tenpoints2_4():
'''
2.4 Nachtägliches Annotieren von Datensätzen, z.B. hinzufügen einer
Description oder einer Zahl
'''
c
=
h
.
Container
()
c
=
db
.
Container
()
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDoubleProperty
"
,
description
=
"
simple double property (from test_tenpoints.py)
"
,
datatype
=
'
double
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_tenpoints.py)
"
,
datatype
=
'
integer
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_tenpoints.py)
"
,
datatype
=
'
datetime
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleFileProperty
"
,
description
=
"
simple file property (from test_tenpoints.py)
"
,
datatype
=
'
file
'
))
c
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
CommentProperty
"
,
description
=
"
comment property
"
,
datatype
=
'
text
'
))
c
.
insert
()
d
=
h
.
Container
()
d
=
db
.
Container
()
d
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
SimpleRecordType
"
,
description
=
"
simple recordType (from test_tenpoints.py)
"
)
.
add_property
(
name
=
'
SimpleTextProperty
'
,
...
...
@@ -492,11 +494,12 @@ def test_tenpoints2_4():
name
=
'
SimpleFileProperty
'
))
d
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
ReferenceProperty
"
,
description
=
'
reference property (from test_tenpoints.py)
'
,
datatype
=
"
SimpleRecordType
"
))
d
.
append
(
h
.
RecordType
(
name
=
"
ComplexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints.py)
"
)
d
.
append
(
db
.
RecordType
(
name
=
"
ComplexRecordType
"
,
description
=
"
complex recordType with references (from test_tenpoints)
"
)
.
add_property
(
name
=
'
ReferenceProperty
'
)
# first method
# second method, doesn't need the ReferenceProperty
.
add_property
(
name
=
'
SimpleRecordType
'
)
...
...
@@ -510,10 +513,10 @@ def test_tenpoints2_4():
f
.
close
()
'''
prepare file record
'''
e
=
h
.
Container
()
e
.
append
(
h
.
File
(
id
=-
1
,
path
=
'
testfiles/testfile
'
,
file
=
"
test.dat
"
))
e
=
db
.
Container
()
e
.
append
(
db
.
File
(
id
=-
1
,
path
=
'
testfiles/testfile
'
,
file
=
"
test.dat
"
))
sr
=
(
h
.
Record
().
add_parent
(
name
=
"
SimpleRecordType
"
)
sr
=
(
db
.
Record
().
add_parent
(
name
=
"
SimpleRecordType
"
)
.
add_property
(
name
=
"
SimpleTextProperty
"
,
value
=
"
Some Text
"
)
.
add_property
(
name
=
"
SimpleDoubleProperty
"
,
value
=
3.14
)
.
add_property
(
name
=
"
SimpleIntegerProperty
"
,
value
=
1337
)
...
...
@@ -523,7 +526,7 @@ def test_tenpoints2_4():
e
.
append
(
sr
).
insert
()
cr1
=
(
h
.
Record
(
db
.
Record
(
name
=
"
My special unique record name
"
).
add_parent
(
name
=
"
ComplexRecordType
"
)
.
add_property
(
name
=
"
ReferenceProperty
"
,
...
...
@@ -531,28 +534,29 @@ def test_tenpoints2_4():
cr1
.
insert
()
cr2
=
(
h
.
Record
().
add_parent
(
name
=
"
ComplexRecordType
"
)
cr2
=
(
db
.
Record
().
add_parent
(
name
=
"
ComplexRecordType
"
)
.
add_property
(
name
=
"
SimpleRecordType
"
,
value
=
sr
))
recid
=
cr2
.
insert
().
id
'''
annotate file
'''
h
.
File
(
db
.
File
(
path
=
'
testfiles/testfile
'
).
retrieve
().
add_property
(
c
.
get_entity_by_name
(
"
CommentProperty
"
),
value
=
"
This is a really nice file.
"
).
update
()
'''
annotate records
'''
h
.
Record
(
db
.
Record
(
name
=
"
My special unique record name
"
).
retrieve
().
add_property
(
c
.
get_entity_by_name
(
"
CommentProperty
"
),
value
=
"
This is a really nice record.
"
).
update
()
h
.
Record
(
db
.
Record
(
id
=
recid
).
retrieve
().
add_property
(
c
.
get_entity_by_name
(
"
CommentProperty
"
),
value
=
"
I don
'
t like this record.
"
).
update
()
h
.
execute_query
(
"
FIND RECORD SimpleRecordType WITH SimpleIntegerProperty=1337 AND SimpleTextProperty=
'
Some Text
'"
,
db
.
execute_query
(
"
FIND RECORD SimpleRecordType WITH SimpleIntegerProperty=1337
"
"
AND SimpleTextProperty=
'
Some Text
'"
,
unique
=
True
).
add_property
(
c
.
get_entity_by_name
(
"
CommentProperty
"
),
value
=
"
I looove this record!!!!!11.
"
).
update
()
...
...
@@ -561,18 +565,18 @@ def test_tenpoints2_4():
def
test_existence
():
try
:
h
.
Property
(
name
=
"
SimpleTextProperty
"
).
retrieve
(
unique
=
True
)
db
.
Property
(
name
=
"
SimpleTextProperty
"
).
retrieve
(
unique
=
True
)
except
CaosDB
Exception
:
except
LinkAhead
Exception
:
print
(
"
SimpleTextProperty does not exist!
"
)
p
=
h
.
Property
(
p
=
db
.
Property
(
name
=
"
SimpleTextProperty
"
,
description
=
"
simple text property (from test_tenpoints.py)
"
,
datatype
=
'
text
'
).
insert
()
if
int
(
h
.
Property
(
db
.
Property
(
name
=
"
SimpleTextProperty
"
).
retrieve
(
unique
=
True
).
id
)
>=
0
:
print
(
"
SimpleTextProperty does exist!
"
)
...
...
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