Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jupyter-openbis-gui-widget
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
openbis
openbis-public
jupyter
jupyter-openbis-gui-widget
Commits
be1532d3
Commit
be1532d3
authored
6 years ago
by
Swen Vermeul
Browse files
Options
Downloads
Patches
Plain Diff
added some tests
parent
813e441d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/conftest.py
+26
-2
26 additions, 2 deletions
tests/conftest.py
tests/test_connection.py
+46
-3
46 additions, 3 deletions
tests/test_connection.py
with
72 additions
and
5 deletions
tests/conftest.py
+
26
−
2
View file @
be1532d3
import
pytest
import
pytest
import
time
import
time
import
random
from
pybis
import
Openbis
from
pybis
import
Openbis
...
@@ -7,10 +8,24 @@ openbis_url = 'https://localhost:8443'
...
@@ -7,10 +8,24 @@ openbis_url = 'https://localhost:8443'
admin_username
=
'
admin
'
admin_username
=
'
admin
'
admin_password
=
'
changeit
'
admin_password
=
'
changeit
'
@pytest.yield_fixture
(
scope
=
"
module
"
)
def
url
():
yield
openbis_url
@pytest.yield_fixture
(
scope
=
"
module
"
)
def
username
():
yield
admin_username
@pytest.yield_fixture
(
scope
=
"
module
"
)
def
password
():
yield
admin_password
@pytest.yield_fixture
(
scope
=
"
module
"
)
@pytest.yield_fixture
(
scope
=
"
module
"
)
def
openbis_instance
():
def
openbis_instance
():
instance
=
Openbis
(
url
=
openbis_url
,
verify_certificates
=
False
)
instance
=
Openbis
(
url
=
openbis_url
,
verify_certificates
=
False
)
instance
.
login
(
admin_username
,
admin_password
)
print
(
"
\n
LOGGING IN...
"
)
print
(
"
\n
LOGGING IN...
"
)
print
(
instance
.
is_session_active
())
timestamp
=
time
.
strftime
(
'
%a_%y%m%d_%H%M%S
'
).
upper
()
timestamp
=
time
.
strftime
(
'
%a_%y%m%d_%H%M%S
'
).
upper
()
space_code
=
'
test_space_
'
+
timestamp
space_code
=
'
test_space_
'
+
timestamp
...
@@ -22,11 +37,20 @@ def openbis_instance():
...
@@ -22,11 +37,20 @@ def openbis_instance():
project
.
save
()
project
.
save
()
experiment_code
=
"
TEST-EXPERIMENT-{:04d}
"
.
format
(
random
.
randint
(
0
,
9999
))
experiment_code
=
"
TEST-EXPERIMENT-{:04d}
"
.
format
(
random
.
randint
(
0
,
9999
))
experiment
=
instance
.
new_experiment
(
code
=
experiment_code
,
space
=
space
,
project
=
project
)
experiment
=
instance
.
new_experiment
(
code
=
experiment_code
,
type
=
'
DEFAULT_EXPERIMENT
'
,
project
=
project
,
)
experiment
.
save
()
experiment
.
save
()
sample_code
=
"
TEST-SAMPLE-{:04d}
"
.
format
(
random
.
randint
(
0
,
9999
))
sample_code
=
"
TEST-SAMPLE-{:04d}
"
.
format
(
random
.
randint
(
0
,
9999
))
sample
=
instance
.
new_sample
(
code
=
sample_code
,
space
=
space
,
project
=
project
)
sample
=
instance
.
new_sample
(
code
=
sample_code
,
type
=
'
UNKNOWN
'
,
space
=
space
,
experiment
=
experiment
,
)
sample
.
save
()
sample
.
save
()
instance
.
login
(
admin_username
,
admin_password
)
instance
.
login
(
admin_username
,
admin_password
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_connection.py
+
46
−
3
View file @
be1532d3
import
pytest
import
pytest
import
importlib
import
importlib
j
upyterserver
=
importlib
.
import_module
(
"
jupyter-openbis-extension
"
)
j
s
=
importlib
.
import_module
(
"
jupyter-openbis-extension
"
)
def
test_conn
():
def
test_conn
(
url
,
username
,
password
):
pass
conn
=
js
.
connection
.
OpenBISConnection
(
name
=
"
test-conn
"
,
url
=
url
,
username
=
username
,
password
=
password
,
verify_certificates
=
False
,
)
info
=
conn
.
get_info
()
assert
isinstance
(
info
,
dict
)
assert
info
[
'
name
'
]
==
'
test-conn
'
assert
info
[
'
url
'
]
==
url
assert
info
[
'
username
'
]
==
username
assert
info
[
'
password
'
]
==
password
assert
conn
.
status
==
'
not connected
'
try
:
conn
.
login
()
except
Exception
:
pass
assert
conn
.
status
==
'
connected
'
assert
conn
.
is_session_active
()
==
True
def
test_conn_login
(
url
,
username
,
password
):
conn
=
js
.
connection
.
OpenBISConnection
(
name
=
"
test-conn
"
,
url
=
url
,
verify_certificates
=
False
,
)
assert
conn
.
status
==
'
not connected
'
try
:
conn
.
login
(
username
,
password
)
except
Exception
:
pass
assert
conn
.
status
==
"
connected
"
def
test_dataset
(
openbis_instance
):
pass
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