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
b8129f07
Commit
b8129f07
authored
8 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into f-fix-login-failed-on-long-request
parents
b27a55a3
e15a74fc
No related branches found
No related tags found
1 merge request
!83
Add test for https://gitlab.com/linkahead/linkahead-pylib/-/issues/103
Pipeline
#58117
passed
8 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
README.md
+7
-6
7 additions, 6 deletions
README.md
tests/test_issues_pylib.py
+26
-0
26 additions, 0 deletions
tests/test_issues_pylib.py
tests/test_server_side_scripting.py
+31
-30
31 additions, 30 deletions
tests/test_server_side_scripting.py
with
65 additions
and
36 deletions
CHANGELOG.md
+
1
−
0
View file @
b8129f07
...
...
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added (for new features)
*
Test for
[
caosdb-pylib#89
](
https://gitlab.com/linkahead/linkahead-pylib/-/issues/89
)
*
Test for
[
caosdb-pylib#103
](
https://gitlab.com/linkahead/linkahead-pylib/-/issues/103
)
*
Tests for entity state
[
caosdb-server!62
](
https://gitlab.com/caosdb/caosdb-server/-/merge_requests/62
)
*
Tests for version history
...
...
This diff is collapsed.
Click to expand it.
README.md
+
7
−
6
View file @
b8129f07
...
...
@@ -17,13 +17,14 @@ CaosDB project.
which points to the
`resources`
directory here in the pyinttest repository. You can create a
symlink like that with the following command (adapt paths to match your setting):
`custom$ ln -s ../../../../caosdb-pyinttest/resources debug-scripting-bin`
-
Modify
`py
caosdb
.ini.template`
and save it as
`py
caosdb
.ini`
, taking care of the following points:
-
Certificates must be valid and be specified in
`py
caosdb
.ini`
.
-
Modify
`py
linkahead
.ini.template`
and save it as
`py
linkahead
.ini`
, taking care of the following points:
-
Certificates must be valid and be specified in
`py
linkahead
.ini`
.
-
Server-side scripting paths must be given, otherwise server-side scripting will be omitted.
-
The local path
`test_server_side_scripting.bin_dir.local`
should point to a
`linkahead-server/scripting/bin`
somwhere.
-
The remote path
`test_server_side_scripting.bin_dir.server`
should probably be something like
`/opt/caosdb/git/caosdb-server/scripting/bin-debug`
.
-
The
*local*
path
`test_server_side_scripting.bin_dir.local`
should point to the
`linkahead-server/scripting/bin`
directory in linkahead-server sources.
-
The
*remote*
path
`test_server_side_scripting.bin_dir.server`
should probably be something
like
`/opt/caosdb/git/caosdb-server/scripting/bin-debug`
. This is the path as seen by the
server (in most cases inside the docker container).
-
Paths for the file tests must exist, or be creatable by the testing script and the server.
-
Run the tests with
`pytest`
or
`pytest-3`
(depending on your system).
-
If you want to run just a single test, you can also select a single test file:
...
...
This diff is collapsed.
Click to expand it.
tests/test_issues_pylib.py
+
26
−
0
View file @
b8129f07
...
...
@@ -28,8 +28,10 @@ import math
import
os
import
tempfile
import
time
import
warnings
import
linkahead
as
db
import
linkahead.common.utils
import
pytest
from
linkahead
import
administration
as
admin
...
...
@@ -66,6 +68,30 @@ def teardown_function(function):
# ########################### Issue tests start here #####################
def
test_gitlab_com_89
():
"""
Test that after retrieving an entity from the server, generating an xml
string and subsequently recreating the container from xml does not
generate any errors.
See https://gitlab.com/linkahead/linkahead-pylib/-/issues/89 and
https://gitlab.indiscale.com/caosdb/customers/f-fit/management/-/issues/81
"""
# We need a container generated with data from the server
rt
=
db
.
RecordType
(
name
=
"
TestType
"
)
rt
.
insert
()
container
=
db
.
execute_query
(
"
FIND RECORDTYPE *
"
)
# With this container, to_xml, xml2str, and from_xml should not generate
# warnings - the simplefilter means that any warning fails the test
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"
error
"
)
xml_str
=
linkahead
.
common
.
utils
.
xml2str
(
container
.
to_xml
())
cont_from_xml
=
db
.
Container
.
from_xml
(
xml_str
)
assert
len
(
cont_from_xml
)
==
len
(
container
)
assert
cont_from_xml
[
0
].
name
==
rt
.
name
def
test_gitlab_com_103
():
"""
Test that after causing an UriTooLong error the used auth_token
...
...
This diff is collapsed.
Click to expand it.
tests/test_server_side_scripting.py
+
31
−
30
View file @
b8129f07
# -*- 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) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
...
...
@@ -33,13 +33,13 @@ import ssl
import
tempfile
from
http.client
import
HTTPSConnection
from
caosdb
import
Info
,
RecordType
from
caosdb
import
administration
as
admin
from
caosdb
import
execute_query
,
get_config
,
get_connection
from
caosdb
.connection.encode
import
MultipartParam
,
multipart_encode
from
caosdb
.connection.utils
import
urlencode
,
urlparse
from
caosdb
.exceptions
import
HTTPClientError
,
HTTPResourceNotFoundError
from
caosdb
.utils.server_side_scripting
import
run_server_side_script
from
linkahead
import
Info
,
RecordType
from
linkahead
import
administration
as
admin
from
linkahead
import
execute_query
,
get_config
,
get_connection
from
linkahead
.connection.encode
import
MultipartParam
,
multipart_encode
from
linkahead
.connection.utils
import
urlencode
,
urlparse
from
linkahead
.exceptions
import
HTTPClientError
,
HTTPResourceNotFoundError
from
linkahead
.utils.server_side_scripting
import
run_server_side_script
from
lxml
import
etree
from
pytest
import
mark
,
raises
...
...
@@ -142,6 +142,29 @@ def teardown_module():
clean_database
()
def
request
(
method
,
headers
,
path
,
body
=
None
):
"""
Connect without auth-token.
This is clumsy because the pylib is not intended to be used as anonymous user.
"""
context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLSv1_2
)
context
.
verify_mode
=
ssl
.
CERT_REQUIRED
if
hasattr
(
context
,
"
check_hostname
"
):
context
.
check_hostname
=
True
context
.
load_verify_locations
(
get_config
().
get
(
"
Connection
"
,
"
cacert
"
))
url
=
get_config
().
get
(
"
Connection
"
,
"
url
"
)
fullurl
=
urlparse
(
url
)
http_con
=
HTTPSConnection
(
str
(
fullurl
.
netloc
),
timeout
=
200
,
context
=
context
)
http_con
.
request
(
method
=
method
,
headers
=
headers
,
url
=
str
(
fullurl
.
path
)
+
path
,
body
=
body
)
return
http_con
.
getresponse
()
def
test_call_script_non_existing
():
form
=
dict
()
form
[
"
call
"
]
=
"
non_existing_script
"
...
...
@@ -355,28 +378,6 @@ def test_call_as_anonymous_with_administration_role():
assert
"
exception
"
not
in
diagnostics
[
"
caosdb
"
]
def
request
(
method
,
headers
,
path
,
body
=
None
):
"""
Connect without auth-token. This is clumsy, bc the pylib is not
intended to be used as anonymous user.
"""
context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLSv1_2
)
context
.
verify_mode
=
ssl
.
CERT_REQUIRED
if
hasattr
(
context
,
"
check_hostname
"
):
context
.
check_hostname
=
True
context
.
load_verify_locations
(
get_config
().
get
(
"
Connection
"
,
"
cacert
"
))
url
=
get_config
().
get
(
"
Connection
"
,
"
url
"
)
fullurl
=
urlparse
(
url
)
http_con
=
HTTPSConnection
(
str
(
fullurl
.
netloc
),
timeout
=
200
,
context
=
context
)
http_con
.
request
(
method
=
method
,
headers
=
headers
,
url
=
str
(
fullurl
.
path
)
+
path
,
body
=
body
)
return
http_con
.
getresponse
()
def
test_anonymous_script_calling_not_permitted
():
form
=
dict
()
form
[
"
call
"
]
=
"
ok
"
...
...
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