Skip to content

Commit

Permalink
General testing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvisscher committed Mar 4, 2024
1 parent 3429686 commit 7e53124
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
6 changes: 4 additions & 2 deletions activity_browser/actions/database/database_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class DatabaseExport(ABAction):
title = "Export database..."
tool_tip = "Export a database from this project"

wizard: DatabaseExportWizard

def onTrigger(self, toggled):
wizard = DatabaseExportWizard(application.main_window)
wizard.show()
self.wizard = DatabaseExportWizard(application.main_window)
self.wizard.show()
5 changes: 3 additions & 2 deletions activity_browser/actions/database/database_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class DatabaseImport(ABAction):
icon = qicons.import_db
title = "Import database..."
tool_tip = "Import a new database"
wizard: DatabaseImportWizard

def onTrigger(self, toggled):
wizard = DatabaseImportWizard(application.main_window)
wizard.show()
self.wizard = DatabaseImportWizard(application.main_window)
self.wizard.show()
9 changes: 8 additions & 1 deletion tests/actions/test_activity_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
from activity_browser.ui.widgets.dialog import LocationLinkingDialog, ActivityLinkingDialog


def test_activity_delete(ab_app):
def test_activity_delete(ab_app, monkeypatch):
key = ('activity_tests', '330b935a46bc4ad39530ab7df012f38b')

monkeypatch.setattr(
QtWidgets.QMessageBox, 'warning',
staticmethod(lambda *args, **kwargs: QtWidgets.QMessageBox.Yes)
)


assert bw.projects.current == "default"
assert bw.get_activity(key)

Expand Down
19 changes: 19 additions & 0 deletions tests/actions/test_database_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ def test_database_duplicate(ab_app, monkeypatch, qtbot):

def test_database_export(ab_app):
# TODO: implement when we've redone the export wizard and actions
action = actions.DatabaseExport(None)
action.trigger()
assert action.wizard.isVisible()
action.wizard.destroy()
return


def test_database_import(ab_app):
# TODO: implement when we've redone the import wizard and actions
action = actions.DatabaseImport(None)
action.trigger()
assert action.wizard.isVisible()
action.wizard.destroy()
return


Expand All @@ -61,13 +69,24 @@ def test_database_new(ab_app, monkeypatch):
staticmethod(lambda *args, **kwargs: ('db_that_is_new', True))
)

monkeypatch.setattr(
QtWidgets.QMessageBox, 'information',
staticmethod(lambda *args, **kwargs: True)
)

assert bw.projects.current == "default"
assert new_db not in bw.databases

actions.DatabaseNew(None).trigger()

assert new_db in bw.databases

db_number = len(bw.databases)

actions.DatabaseNew(None).trigger()

assert db_number == len(bw.databases)


def test_database_relink(ab_app, monkeypatch):
db = "db_to_relink"
Expand Down
Binary file modified tests/pytest_base.gz
Binary file not shown.

0 comments on commit 7e53124

Please sign in to comment.