Ignore:
Timestamp:
Feb 2, 2018 9:21:48 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
a90c9c5
Parents:
5e66738
Message:

More code review related fixes

Location:
src/sas/qtgui/Perspectives/Fitting/UnitTesting
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py

    rda9a0722 r14ec91c5  
    1515# Local 
    1616from sas.qtgui.Perspectives.Fitting.ConstraintWidget import ConstraintWidget 
    17 from sas.qtgui.Perspectives.Fitting.Constraints import Constraint 
     17from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 
    1818 
    1919if not QtWidgets.QApplication.instance(): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingOptionsTest.py

    r53c771e r14ec91c5  
    11import sys 
    22import unittest 
     3import webbrowser 
    34from bumps import options 
    45 
     
    114115 
    115116    # test disabled until pyQt5 works well 
    116     def notestOnHelp(self): 
     117    def testOnHelp(self): 
    117118        ''' Test help display''' 
    118         #Mock the QWebView method 
    119         QtWebKit.QWebView.show = MagicMock() 
    120         QtWebKit.QWebView.load = MagicMock() 
     119        webbrowser.open = MagicMock() 
    121120 
    122121        # Invoke the action on default tab 
    123122        self.widget.onHelp() 
    124123        # Check if show() got called 
    125         self.assertTrue(QtWebKit.QWebView.show.called) 
     124        self.assertTrue(webbrowser.open.called) 
    126125        # Assure the filename is correct 
    127         self.assertIn("optimizer.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     126        self.assertIn("optimizer.html", webbrowser.open.call_args[0][0]) 
    128127 
    129128        # Change the combo index 
     
    131130        self.widget.onHelp() 
    132131        # Check if show() got called 
    133         self.assertEqual(QtWebKit.QWebView.show.call_count, 2) 
     132        self.assertEqual(webbrowser.open.call_count, 2) 
    134133        # Assure the filename is correct 
    135         self.assertIn("fit-dream", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     134        self.assertIn("fit-dream", webbrowser.open.call_args[0][0]) 
    136135 
    137136        # Change the index again 
     
    139138        self.widget.onHelp() 
    140139        # Check if show() got called 
    141         self.assertEqual(QtWebKit.QWebView.show.call_count, 3) 
     140        self.assertEqual(webbrowser.open.call_count, 3) 
    142141        # Assure the filename is correct 
    143         self.assertIn("fit-lm", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     142        self.assertIn("fit-lm", webbrowser.open.call_args[0][0]) 
    144143 
    145144    def testWidgetFromOptions(self): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    r63319b0 r14ec91c5  
    1717from sas.qtgui.Utilities.GuiUtils import * 
    1818from sas.qtgui.Perspectives.Fitting.FittingWidget import * 
    19 from sas.qtgui.Perspectives.Fitting.Constraints import Constraint 
     19from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 
    2020 
    2121from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy 
     
    787787            self.assertEqual(update_spy.count(), 1) 
    788788 
    789     # test disabled until pyqt5 deals with html properly 
    790     def notestOnHelp(self): 
     789    def testOnHelp(self): 
    791790        """ 
    792791        Test various help pages shown in this widget 
    793792        """ 
    794         #Mock the QWebView method 
    795         QtWebKit.QWebView.show = MagicMock() 
    796         QtWebKit.QWebView.load = MagicMock() 
     793        #Mock the webbrowser.open method 
     794        self.widget.parent.showHelp = MagicMock() 
     795        #webbrowser.open = MagicMock() 
    797796 
    798797        # Invoke the action on default tab 
    799798        self.widget.onHelp() 
    800799        # Check if show() got called 
    801         self.assertTrue(QtWebKit.QWebView.show.called) 
     800        self.assertTrue(self.widget.parent.showHelp.called) 
    802801        # Assure the filename is correct 
    803         self.assertIn("fitting_help.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     802        self.assertIn("fitting_help.html", self.widget.parent.showHelp.call_args[0][0]) 
    804803 
    805804        # Change the tab to options 
     
    807806        self.widget.onHelp() 
    808807        # Check if show() got called 
    809         self.assertEqual(QtWebKit.QWebView.show.call_count, 2) 
     808        self.assertEqual(self.widget.parent.showHelp.call_count, 2) 
    810809        # Assure the filename is correct 
    811         self.assertIn("residuals_help.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     810        self.assertIn("residuals_help.html", self.widget.parent.showHelp.call_args[0][0]) 
    812811 
    813812        # Change the tab to smearing 
     
    815814        self.widget.onHelp() 
    816815        # Check if show() got called 
    817         self.assertEqual(QtWebKit.QWebView.show.call_count, 3) 
     816        self.assertEqual(self.widget.parent.showHelp.call_count, 3) 
    818817        # Assure the filename is correct 
    819         self.assertIn("sm_help.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     818        self.assertIn("resolution.html", self.widget.parent.showHelp.call_args[0][0]) 
    820819 
    821820        # Change the tab to poly 
     
    823822        self.widget.onHelp() 
    824823        # Check if show() got called 
    825         self.assertEqual(QtWebKit.QWebView.show.call_count, 4) 
     824        self.assertEqual(self.widget.parent.showHelp.call_count, 4) 
    826825        # Assure the filename is correct 
    827         self.assertIn("pd_help.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     826        self.assertIn("polydispersity.html", self.widget.parent.showHelp.call_args[0][0]) 
    828827 
    829828        # Change the tab to magnetism 
     
    831830        self.widget.onHelp() 
    832831        # Check if show() got called 
    833         self.assertEqual(QtWebKit.QWebView.show.call_count, 5) 
     832        self.assertEqual(self.widget.parent.showHelp.call_count, 5) 
    834833        # Assure the filename is correct 
    835         self.assertIn("mag_help.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     834        self.assertIn("magnetism.html", self.widget.parent.showHelp.call_args[0][0]) 
    836835 
    837836    def testReadFitPage(self): 
Note: See TracChangeset for help on using the changeset viewer.