Skip to content

Commit 18495c2

Browse files
committed
tests: allow to use different DCOR instance for testing
1 parent f6d8b99 commit 18495c2

7 files changed

Lines changed: 12 additions & 9 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.16.12
2+
- tests: allow to use different DCOR instance for testing
23
- tests: make tests independent of testing user
34
0.16.11
45
- fix: support CKAN 2.11 (authorization and status_show)

tests/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
api_key
1+
api_key*

tests/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
from dcoraid.upload import UploadQueue
1414

1515

16-
SERVER = "dcor-dev.mpl.mpg.de"
16+
# You can run e.g. tests on a local DCOR instance with
17+
# export DCORAID_TEST_SERVER="http://192.168.122.143"
18+
SERVER = os.environ.get("DCORAID_TEST_SERVER", "dcor-dev.mpl.mpg.de")
19+
1720
dpath = pathlib.Path(__file__).parent / "data" / "calibration_beads_47.rtdc"
1821

1922

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def pytest_configure(config):
5252
settings.setIniCodec("utf-8")
5353
settings.setValue("check for updates", "0")
5454
settings.setValue("user scenario", "dcor-dev")
55-
settings.setValue("auth/server", "dcor-dev.mpl.mpg.de")
55+
settings.setValue("auth/server", common.SERVER)
5656
settings.setValue("auth/api key", common.get_api_key())
5757
settings.setValue("debug/without timers", "1")
5858
settings.sync()

tests/test_api_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_api_requests_cache_no_parameters():
1313
t0 = time.perf_counter()
1414
api.get("status_show")
1515
t1 = time.perf_counter()
16-
for ii in range(50):
16+
for ii in range(20):
1717
api.get("status_show")
1818
t2 = time.perf_counter()
1919
assert (t1 - t0) > (t2 - t1)
@@ -25,7 +25,7 @@ def test_api_requests_cache_with_parameters():
2525
t0 = time.perf_counter()
2626
api.get("organization_list_for_user", permission="create_dataset")
2727
t1 = time.perf_counter()
28-
for ii in range(50):
28+
for ii in range(20):
2929
api.get("organization_list_for_user", permission="create_dataset")
3030
t2 = time.perf_counter()
3131
assert (t1 - t0) > (t2 - t1)

tests/test_dbmodel_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ def test_get_collections():
3838

3939

4040
def test_get_users_anonymous():
41-
api = CKANAPI(server="dcor-dev.mpl.mpg.de")
41+
api = common.get_api()
4242
db = db_api.APIInterrogator(api=api)
4343
with pytest.raises(errors.APIAuthorizationError, match="Access denied"):
4444
db.get_users()
4545

4646

4747
def test_public_api_interrogator():
48-
"""This test uses the figshare datasets on SERVER"""
4948
api = common.get_api()
5049
db = db_api.APIInterrogator(api=api)
5150
defaults = common.get_test_defaults()

tests/test_gui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def mw(qtbot):
2727
QtCore.QSettings.setDefaultFormat(QtCore.QSettings.IniFormat)
2828
settings = QtCore.QSettings()
2929
settings.setIniCodec("utf-8")
30-
settings.setValue("auth/server", "dcor-dev.mpl.mpg.de")
30+
settings.setValue("auth/server", common.SERVER)
3131
QtTest.QTest.qWait(100)
3232
QtWidgets.QApplication.processEvents(QtCore.QEventLoop.AllEvents, 5000)
3333
# Code that will run before your test
@@ -165,7 +165,7 @@ def test_gui_start_with_bad_server(qtbot):
165165
raise
166166
finally:
167167
# reset to testing defaults
168-
settings.setValue("auth/server", "dcor-dev.mpl.mpg.de")
168+
settings.setValue("auth/server", common.SERVER)
169169

170170

171171
def test_gui_start_with_bad_api_key(qtbot):

0 commit comments

Comments
 (0)