Skip to content

Commit

Permalink
maybe fixed pytest workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cudmore committed Jun 27, 2024
1 parent ab2b7d0 commit 19fc40c
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/interface/test_editEvent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import pytest

import mapmanagercore.data

from pymapmanager.interface2 import PyMapManagerApp
from pymapmanager.interface2.stackWidgets import stackWidget2
from pymapmanager.interface2.stackWidgets.event.spineEvent import EditSpinePropertyEvent, DeleteSpineEvent
from pymapmanager._logger import logger

# this makes qapp be our PyMapManagerApp, it is derived from QApplication
@pytest.fixture(scope="session")
def qapp_cls():
return PyMapManagerApp

@pytest.fixture
def stackWidgetObject(qtbot, qapp):
# path = '../PyMapManager-Data/maps/rr30a/rr30a_s0_ch2.tif'
path = mapmanagercore.data.getSingleTimepointMap()
sw = stackWidget2(path=path)

# sw.showScatterPlot2(show=True)
# sw.showAnalysisParams()

return sw

def test_deleteSpine(stackWidgetObject, qapp):
spineID = 2
dse = DeleteSpineEvent(stackWidgetObject, spineID=spineID)

def test_editSpineProperty(stackWidgetObject, qapp):
logger.info('')

assert stackWidgetObject is not None
assert isinstance(stackWidgetObject, stackWidget2)

# path = '../PyMapManager-Data/maps/rr30a/rr30a_s0_ch2.tif'
# sw = stackWidget2(path=path)

spineID = 2
col = 'userType'
value = 12

esp = EditSpinePropertyEvent(stackWidgetObject, spineID=spineID, col=col, value=value)

spineID = 5
col = 'accept'
value = True # str, int, float
esp.addEdit(spineID, col, value)

for idx, oneEdit in enumerate(esp):
print(' ', idx, oneEdit)

# print('getList:', esp.getList())

59 changes: 59 additions & 0 deletions tests/interface/test_stack_widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
import sys
import pytest

import mapmanagercore.data

from pymapmanager.interface2.pyMapManagerApp2 import PyMapManagerApp
from pymapmanager.interface2.stackWidgets import stackWidget2

from pymapmanager._logger import logger

# this makes qapp be our PyMapManagerApp, it is derived from QApplication
@pytest.fixture(scope="session")
def qapp_cls():
return PyMapManagerApp

# def test_stack_plugins():
# # logger.info(f'calling pyMapManagerApp.loadPlugins()')

# app = PyMapManagerApp()

# _stack = app.getStackPluginDict()
# _map = app.getMapPluginDict()

# # for k,v in pluginDict.items():
# # logger.info(k)
# # # logger.info(v)
# # for k2, v2 in v.items():
# # logger.info(f' {k2}: {v2}')

def test_plugins(qtbot, qapp):
"""Run all plugins through a number of different tests.
"""

print('qapp:', qapp)

mmapPath = mapmanagercore.data.getSingleTimepointMap()

logger.info(f'opening stack widget path {mmapPath}')
stackWidgetWindow = stackWidget2(path=mmapPath)

# get list of all stack widgets from app, keys are class of plugin
stackPluginDict = qapp.getStackPluginDict()

for pluginName, _dict in stackPluginDict.items():
# if pluginName in ['Point List', 'Line List', 'Histogram', 'Search Widget', 'Selection Widget']:
# stackWidgetWindow.runPlugin(pluginName)

if pluginName in ['Stack Widget', 'line plot', 'point plot', 'not assigned']:
# stack widget is special
continue

logger.info(f'running plugin: {pluginName}')
stackWidgetWindow.runPlugin(pluginName)

stackWidgetWindow.zoomToPointAnnotation(5)

if __name__ == '__main__':
pass

0 comments on commit 19fc40c

Please sign in to comment.