Changeset 4ea8020 in sasview for src/sas/qtgui/Perspectives/Fitting/UnitTesting
- Timestamp:
- Sep 7, 2018 9:40:56 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- c0de493
- Parents:
- 0109f2a (diff), dcabba7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Torin Cooper-Bennun <40573959+tcbennun@…> (09/07/18 09:40:56)
- git-committer:
- GitHub <noreply@…> (09/07/18 09:40:56)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r3fbd77b r4ea8020 18 18 from sas.qtgui.Perspectives.Fitting.FittingWidget import * 19 19 from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 20 20 import sas.qtgui.Utilities.LocalConfig 21 21 from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy 22 from sas.qtgui.Perspectives.Fitting.ModelThread import Calc1D 23 from sas.qtgui.Perspectives.Fitting.ModelThread import Calc2D 22 24 23 25 from sas.qtgui.Plotting.PlotterData import Data1D … … 260 262 self.widget.cbModel.setCurrentIndex(0) 261 263 262 # Observe factor reset to None263 self.assertEqual(self.widget.cbStructureFactor.currentText(), STRUCTURE_DEFAULT)264 # Observe factor doesn't reset to None 265 self.assertEqual(self.widget.cbStructureFactor.currentText(), 'squarewell') 264 266 265 267 # Switch category to structure factor … … 319 321 Check that the fitting 1D data object is ready 320 322 """ 321 # Mock the thread creation 322 threads.deferToThread = MagicMock() 323 # Model for theory 324 self.widget.SASModelToQModel("cylinder") 325 # Call the tested method 326 self.widget.calculateQGridForModel() 327 time.sleep(1) 328 # Test the mock 329 self.assertTrue(threads.deferToThread.called) 330 self.assertEqual(threads.deferToThread.call_args_list[0][0][0].__name__, "compute") 323 324 if LocalConfig.USING_TWISTED: 325 # Mock the thread creation 326 threads.deferToThread = MagicMock() 327 # Model for theory 328 self.widget.SASModelToQModel("cylinder") 329 # Call the tested method 330 self.widget.calculateQGridForModel() 331 time.sleep(1) 332 # Test the mock 333 self.assertTrue(threads.deferToThread.called) 334 self.assertEqual(threads.deferToThread.call_args_list[0][0][0].__name__, "compute") 335 else: 336 Calc2D.queue = MagicMock() 337 # Model for theory 338 self.widget.SASModelToQModel("cylinder") 339 # Call the tested method 340 self.widget.calculateQGridForModel() 341 time.sleep(1) 342 # Test the mock 343 self.assertTrue(Calc2D.queue.called) 331 344 332 345 def testCalculateResiduals(self): … … 417 430 index = self.widget._poly_model.index(0,0) 418 431 419 #self.widget.show()420 #QtWidgets.QApplication(sys.argv).exec_()421 422 432 # Set the checbox 423 433 self.widget._poly_model.item(0,0).setCheckState(2) … … 435 445 self.assertEqual(self.widget.kernel_module.details['radius_bell'][1], 1.0) 436 446 447 #self.widget.show() 448 #QtWidgets.QApplication.exec_() 449 437 450 # Change the number of points 438 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.npts'), 35)451 self.assertEqual(self.widget.poly_params['radius_bell.npts'], 35) 439 452 self.widget._poly_model.item(0,4).setText("22") 440 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.npts'), 22)453 self.assertEqual(self.widget.poly_params['radius_bell.npts'], 22) 441 454 # try something stupid 442 455 self.widget._poly_model.item(0,4).setText("butt") 443 456 # see that this didn't annoy the control at all 444 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.npts'), 22)457 self.assertEqual(self.widget.poly_params['radius_bell.npts'], 22) 445 458 446 459 # Change the number of sigmas 447 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.nsigmas'), 3)460 self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 3) 448 461 self.widget._poly_model.item(0,5).setText("222") 449 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.nsigmas'), 222)462 self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 222) 450 463 # try something stupid again 451 464 self.widget._poly_model.item(0,4).setText("beer") 452 465 # no efect 453 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.nsigmas'), 222)466 self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 222) 454 467 455 468 def testOnPolyComboIndexChange(self): … … 472 485 self.widget.onPolyComboIndexChange('rectangle', 0) 473 486 # check values 474 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.npts'), 35)475 self.assertAlmostEqual(self.widget. kernel_module.getParam('radius_bell.nsigmas'), 1.73205, 5)487 self.assertEqual(self.widget.poly_params['radius_bell.npts'], 35) 488 self.assertAlmostEqual(self.widget.poly_params['radius_bell.nsigmas'], 1.73205, 5) 476 489 # Change the index 477 490 self.widget.onPolyComboIndexChange('lognormal', 0) 478 491 # check values 479 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.npts'), 80)480 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.nsigmas'), 8)492 self.assertEqual(self.widget.poly_params['radius_bell.npts'], 80) 493 self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 8) 481 494 # Change the index 482 495 self.widget.onPolyComboIndexChange('schulz', 0) 483 496 # check values 484 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.npts'), 80)485 self.assertEqual(self.widget. kernel_module.getParam('radius_bell.nsigmas'), 8)497 self.assertEqual(self.widget.poly_params['radius_bell.npts'], 80) 498 self.assertEqual(self.widget.poly_params['radius_bell.nsigmas'], 8) 486 499 487 500 # mock up file load … … 651 664 self.assertEqual(self.widget.cmdPlot.text(), 'Show Plot') 652 665 653 self.widget.show()654 655 666 # Set data 656 667 test_data = Data1D(x=[1,2], y=[1,2]) 657 668 item = QtGui.QStandardItem() 669 updateModelItem(item, test_data, "test") 658 670 # Force same data into logic 659 self.widget.logic.data = test_data 660 self.widget.data_is_loaded = True 671 self.widget.data = item 661 672 662 673 # Change the category index so we have a model available … … 704 715 self.widget.close() 705 716 717 def testOnEmptyFit2(self): 706 718 test_data = Data2D(image=[1.0, 2.0, 3.0], 707 719 err_image=[0.01, 0.02, 0.03], … … 714 726 item = QtGui.QStandardItem() 715 727 updateModelItem(item, test_data, "test") 728 716 729 # Force same data into logic 717 730 self.widget.data = item … … 731 744 self.widget.close() 732 745 733 734 def testOnFit1D(self): 746 def notestOnFit1D(self): 735 747 """ 736 748 Test the threaded fitting call … … 770 782 self.widget.close() 771 783 772 def testOnFit2D(self):784 def notestOnFit2D(self): 773 785 """ 774 786 Test the threaded fitting call … … 865 877 # Set data 866 878 test_data = Data1D(x=[1,2], y=[1,2]) 867 879 item = QtGui.QStandardItem() 880 updateModelItem(item, test_data, "test") 868 881 # Force same data into logic 869 self.widget.logic.data = test_data 870 self.widget.data_is_loaded = True 882 self.widget.data = item 883 884 # Force same data into logic 871 885 category_index = self.widget.cbCategory.findText('Sphere') 886 872 887 self.widget.cbCategory.setCurrentIndex(category_index) 873 888 self.widget.main_params_to_fit = ['scale'] … … 951 966 # Set data 952 967 test_data = Data1D(x=[1,2], y=[1,2]) 953 968 item = QtGui.QStandardItem() 969 updateModelItem(item, test_data, "test") 954 970 # Force same data into logic 955 self.widget.logic.data = test_data 956 self.widget.data_is_loaded = True 971 self.widget.data = item 957 972 category_index = self.widget.cbCategory.findText("Sphere") 958 973 self.widget.cbCategory.setCurrentIndex(category_index) … … 976 991 # Set data 977 992 test_data = Data1D(x=[1,2], y=[1,2]) 978 993 item = QtGui.QStandardItem() 994 updateModelItem(item, test_data, "test") 979 995 # Force same data into logic 980 self.widget.logic.data = test_data 981 self.widget.data_is_loaded = True 996 self.widget.data = item 982 997 category_index = self.widget.cbCategory.findText("Sphere") 983 998
Note: See TracChangeset
for help on using the changeset viewer.