Skip to content

Commit 614dea4

Browse files
committed
enh: speed-up tests by skipping database update on startup
1 parent 8e8dc06 commit 614dea4

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

dcoraid/gui/main.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@ def __init__(self, *args, **kwargs):
142142
QtCore.QStandardPaths.StandardLocation.CacheLocation)
143143
)
144144
self._last_asked_about_update = self.database.local_timestamp
145-
self.check_update_database(
146-
force=bool(int(self.settings.value(
147-
"force update database on startup", "0")))
148-
)
145+
if not bool(int(self.settings.value(
146+
"skip database update on startup", "0"))):
147+
self.check_update_database()
149148
except BaseException:
150149
self.logger.error(traceback.format_exc())
151150
else:
@@ -207,7 +206,9 @@ def check_update_database(self, reset=False, force=False):
207206
"Performing database update, please wait..." + " "*20,
208207
"Abort",
209208
0,
210-
0)
209+
0,
210+
self
211+
)
211212
prog.canceled.connect(abort_event.set)
212213
prog.setMinimumDuration(0)
213214
prog.setModal(True)
@@ -216,10 +217,12 @@ def check_update_database(self, reset=False, force=False):
216217
def prog_update_callback(data):
217218
cdict = data["circle_current"]
218219
new_ds = data["datasets_new"]
219-
circle_name = cdict.get("title", cdict.get("name", "data"))
220-
if len(circle_name) > 50:
221-
circle_name = circle_name[:50] + "..."
222-
prog.setLabelText(f"Fetching '{circle_name}'\n"
220+
title = cdict.get("title")
221+
if not title:
222+
title = cdict.get("name")
223+
if len(title) > 50:
224+
title = title[:50] + "..."
225+
prog.setLabelText(f"Fetching '{title}'\n"
223226
f"Imported {new_ds} datasets so far.")
224227

225228
thr = threading.Thread(target=self.database.update,

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def pytest_configure(config):
6666
settings.setValue(key, value)
6767
# removing timers breaks the user workflow, so it is not in change_settings
6868
settings.setValue("debug/without timers", "1")
69-
settings.setValue("force update database on startup", "1")
69+
settings.setValue("skip database update on startup", "1")
7070
settings.sync()
7171
# cleanup
7272
cleanup_dcoraid_tasks()
@@ -88,7 +88,7 @@ def pytest_unconfigure(config):
8888
settings.setValue(key, USER_SETTINGS[key])
8989
# always remove this setting, because it breaks the user workflow
9090
settings.remove("debug/without timers")
91-
settings.remove("force update database on startup")
91+
settings.remove("skip database update on startup")
9292
settings.sync()
9393
# cleanup
9494
cleanup_dcoraid_tasks()

tests/test_gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_gui_anonymous(qtbot):
6868
"[General]",
6969
"user%20scenario = anonymous",
7070
"check for updates = 0",
71-
"force update database on startup = 1",
71+
"skip database update on startup = 1",
7272
"[auth]",
7373
"api%20key =",
7474
"server = dcor.mpl.mpg.de",

0 commit comments

Comments
 (0)