forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transformWidget_test.py
48 lines (40 loc) · 2.09 KB
/
transformWidget_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
import unittest
from unittest import mock
from mantidqt.utils.qt.testing import start_qapplication
from Muon.GUI.FrequencyDomainAnalysis.FFT import fft_presenter
from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_widget import FFTWidget
from Muon.GUI.FrequencyDomainAnalysis.MaxEnt import maxent_presenter
from Muon.GUI.FrequencyDomainAnalysis.MaxEnt.maxent_widget import MaxEntWidget
from Muon.GUI.FrequencyDomainAnalysis.Transform import transform_view
from Muon.GUI.FrequencyDomainAnalysis.Transform import transform_widget
from Muon.GUI.FrequencyDomainAnalysis.TransformSelection import transform_selection_view
@start_qapplication
class TransformTest(unittest.TestCase):
def setUp(self):
self.load = mock.MagicMock()
self.fft = mock.create_autospec(fft_presenter.FFTPresenter, spec_Set=True)
self.maxent = mock.create_autospec(maxent_presenter.MaxEntPresenter, spec_set=True)
# create widget
self.widget = transform_widget.TransformWidget(self.load, FFTWidget, MaxEntWidget)
# create the view
self.view = mock.create_autospec(transform_view.TransformView, spec_set=False)
self.view.getView = mock.Mock()
self.view.getMethods = mock.Mock(return_value=["FFT", "MaxEnt"])
self.view.hideAll = mock.Mock()
self.view.showMethod = mock.Mock()
self.view.selection = mock.create_autospec(transform_selection_view.TransformSelectionView, spec_set=True)
self.view.selection.changeMethodSignal = mock.Mock()
# set the mocked view to the widget
self.widget.mockWidget(self.view)
def test_changeDisplay(self):
self.widget.updateDisplay(1)
assert (self.view.hideAll.call_count == 1)
self.assertEqual(self.view.showMethod.call_count, 1)
if __name__ == '__main__':
unittest.main()