Changeset 8cb6cd6 in sasview for src/sas/qtgui/UnitTesting


Ignore:
Timestamp:
Jul 12, 2016 8:44:53 AM (8 years ago)
Author:
Piotr Rozyczko <piotr.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:
e3ae090
Parents:
a95260d
Message:

Plot handler prototype + append plot functionality

Location:
src/sas/qtgui/UnitTesting
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/UnitTesting/DataExplorerTest.py

    r0cd8612 r8cb6cd6  
    1717from UnitTesting.TestUtils import QtSignalSpy 
    1818from Plotter import Plotter 
     19import PlotHelper 
    1920 
    2021app = QApplication(sys.argv) 
     
    3940            def perspective(self): 
    4041                return MyPerspective() 
     42            def workspace(self): 
     43                return None 
    4144 
    4245        self.form = DataExplorerWindow(None, dummy_manager()) 
     
    505508        loader = Loader() 
    506509        manager = DataManager() 
     510        PlotHelper.clear() 
     511        self.form.enableGraphCombo(None) 
     512 
     513        # Make sure the controls are disabled 
     514        self.assertFalse(self.form.cbgraph.isEnabled()) 
     515        self.assertFalse(self.form.cmdAppend.isEnabled()) 
    507516 
    508517        # get Data1D 
     
    517526        self.form.plotsFromCheckedItems = MagicMock(return_value=new_data) 
    518527 
     528        # Mask plotting 
     529        self.form.parent.workspace = MagicMock() 
     530 
    519531        # Call the plotting method 
    520532        self.form.newPlot() 
     
    522534        # The plot was displayed 
    523535        self.assertTrue(Plotter.show.called) 
     536 
     537        # The plot was registered 
     538        self.assertEqual(len(PlotHelper.currentPlots()), 1) 
     539 
     540        self.assertTrue(self.form.cbgraph.isEnabled()) 
     541        self.assertTrue(self.form.cmdAppend.isEnabled()) 
     542 
     543    def testAppendPlot(self): 
     544        """ 
     545        Creating new plots from Data1D/2D 
     546        """ 
     547        loader = Loader() 
     548        manager = DataManager() 
     549 
     550        PlotHelper.clear() 
     551        self.form.enableGraphCombo(None) 
     552 
     553        # Make sure the controls are disabled 
     554        self.assertFalse(self.form.cbgraph.isEnabled()) 
     555        self.assertFalse(self.form.cmdAppend.isEnabled()) 
     556 
     557        # get Data1D 
     558        p_file="cyl_400_20.txt" 
     559        output_object = loader.load(p_file) 
     560        new_data = [manager.create_gui_data(output_object, p_file)] 
     561 
     562        # Mask plotting 
     563        self.form.parent.workspace = MagicMock() 
     564 
     565        # Mask the plot show call 
     566        Plotter.show = MagicMock() 
     567 
     568        # Mask retrieval of the data 
     569        self.form.plotsFromCheckedItems = MagicMock(return_value=new_data) 
     570 
     571        # Call the plotting method 
     572        self.form.newPlot() 
     573 
     574        # Call the plotting method again, so we have 2 graphs 
     575        self.form.newPlot() 
     576 
     577        # See that we have two plots 
     578        self.assertEqual(len(PlotHelper.currentPlots()), 2) 
     579 
     580        # Add data to plot #1 
     581        self.form.cbgraph.setCurrentIndex(1) 
     582        self.form.appendPlot() 
     583 
     584        # See that we still have two plots 
     585        self.assertEqual(len(PlotHelper.currentPlots()), 2) 
     586 
     587    def testUpdateGraphCombo(self): 
     588        """ 
     589        Test the combo box update 
     590        """ 
     591        PlotHelper.clear() 
     592 
     593        graph_list=[1,2,3] 
     594        self.form.updateGraphCombo(graph_list) 
     595 
     596        self.assertEqual(self.form.cbgraph.count(), 3) 
     597        self.assertEqual(self.form.cbgraph.currentText(), 'Graph1') 
     598 
     599        graph_list=[] 
     600        self.form.updateGraphCombo(graph_list) 
     601        self.assertEqual(self.form.cbgraph.count(), 0) 
    524602 
    525603    def testUpdateModelFromPerspective(self): 
Note: See TracChangeset for help on using the changeset viewer.