Commit 9d2dd016 authored by payno's avatar payno

[gui][datavalidor] fix unit tests.

parent a7afffc1
......@@ -108,6 +108,12 @@ class DataValidatorOW(widget.OWWidget):
self._widget.sigScanReady.connect(self._scanReadyEmitted)
self._widget._centralWidget.sigConfigChanged.connect(self._updateSettings)
def close(self):
self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self._widget.close()
self._widget = None
widget.OWWidget.close(self)
@Inputs.data_in
def addScan(self, scan):
if scan is None:
......
......@@ -148,8 +148,9 @@ class BaseTestValidation(unittest.TestCase):
shutil.rmtree(cls.rootdir)
def tearDown(self):
self.scanValidator.setAttribute(qt.Qt.WA_DeleteOnClose)
self.scanValidator.close()
del self.scanValidator
self.scanValidator = None
unittest.TestCase.tearDown(self)
def setUp(self):
......@@ -160,14 +161,9 @@ class BaseTestValidation(unittest.TestCase):
class TestValidation(BaseTestValidation):
"""Test validation for the latest data validation widget"""
class _DataValidatorWidgetPatched(DataValidatorOW):
"""A DataValidatorOW without the Orange send signal process"""
scanReady = qt.Signal(TomwerScanBase)
_warnValManualShow = True
def setUp(self):
BaseTestValidation.setUp(self)
self.scanValidator = TestValidation._DataValidatorWidgetPatched()
self.scanValidator = DataValidatorOW()
self.scanValidator._warnValManualShow = True
self.scanValidator._widget.sigScanReady.connect(self.validationReceiver.count)
self.validationReceiver.counter = 0
......
......@@ -107,6 +107,12 @@ class DataValidator(qt.QMainWindow, BaseDataValidator):
_controlButtons.sigChangeReconstructionParametersScan.connect(self.changeReconsParamCurrentScan)
_controlButtons.toggled.connect(self.setManualValidation)
def close(self) -> bool:
self._centralWidget.setAttribute(qt.Qt.WA_DeleteOnClose)
self._centralWidget.close()
self._centralWidget = None
qt.QMainWindow.close(self)
def addScan(self, scan):
"""
......
......@@ -30,6 +30,7 @@ __date__ = "29/05/2017"
import unittest
from . import test_datalist
from . import test_datalistener
from . import test_datavalidator
from . import test_datawatcher
from . import test_h5editor
from . import test_inputwidget
......@@ -42,6 +43,7 @@ def suite():
test_suite.addTests([
test_datalist.suite(),
test_datalistener.suite(),
test_datavalidator.suite(),
test_datawatcher.suite(),
test_h5editor.suite(),
test_inputwidget.suite(),
......
# coding: utf-8
#/*##########################################################################
# Copyright (C) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#############################################################################*/
__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "30/07/2020"
import unittest
from silx.gui.utils.testutils import TestCaseQt
from silx.gui import qt
from tomwer.gui.control.datavalidator import DataValidator
class TestValidatorGUI(TestCaseQt):
"""Test that the ImageStackWidget can be load and remove without any issue
"""
def setUp(self):
TestCaseQt.setUp(self)
self._widget = DataValidator(None)
def tearDown(self):
self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self._widget.close()
self._widget = None
unittest.TestCase.tearDown(self)
def test(self):
"""Make sur the addLeaf and clear functions are working"""
pass
def suite():
test_suite = unittest.TestSuite()
for ui in (TestValidatorGUI, ):
test_suite.addTest(
unittest.defaultTestLoader.loadTestsFromTestCase(ui))
return test_suite
if __name__ == '__main__':
unittest.main(defaultTest="suite")
\ No newline at end of file
......@@ -81,6 +81,12 @@ class DataViewer(qt.QMainWindow):
self._controls.sigDisplayModeChanged.connect(self._updateDisplay)
self._controls.sigDisplayModeChanged.connect(self._reportSettingsUpdate)
def close(self):
self._viewer.setAttribute(qt.Qt.WA_DeleteOnClose)
self._viewer.close()
self._viewer = None
qt.QMainWindow.close(self)
def _urlIndexDelayed(self, *args, **kwargs):
self._viewer.setCurrentUrlIndex(args[0][0])
......
......@@ -29,11 +29,13 @@ __date__ = "29/05/2017"
import unittest
from . import test_sinogramviewer
from . import test_dataviewer
def suite():
test_suite = unittest.TestSuite()
test_suite.addTests([
test_dataviewer.suite(),
test_sinogramviewer.suite(),
])
return test_suite
# coding: utf-8
#/*##########################################################################
# Copyright (C) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#############################################################################*/
__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "30/07/2020"
import unittest
from silx.gui.utils.testutils import TestCaseQt
from silx.gui import qt
from tomwer.gui.visualization.dataviewer import DataViewer, ImageStack
class TestImageStack(TestCaseQt):
"""Test that the ImageStackWidget can be load and remove without any issue
"""
def setUp(self):
TestCaseQt.setUp(self)
self._widget = ImageStack(None)
def tearDown(self):
self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self._widget.close()
self._widget = None
unittest.TestCase.tearDown(self)
def test(self):
"""Make sur the addLeaf and clear functions are working"""
pass
class TestDataViewer(TestCaseQt):
"""Test that the data viewer can be load and remove without any issue"""
def setUp(self):
TestCaseQt.setUp(self)
self._widget = DataViewer(None)
def tearDown(self):
self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self._widget.close()
self._widget = None
unittest.TestCase.tearDown(self)
def test(self):
"""Make sur the addLeaf and clear functions are working"""
pass
def suite():
test_suite = unittest.TestSuite()
for ui in (TestDataViewer, TestImageStack):
test_suite.addTest(
unittest.defaultTestLoader.loadTestsFromTestCase(ui))
return test_suite
if __name__ == '__main__':
unittest.main(defaultTest="suite")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment