Ignore:
Timestamp:
Jul 10, 2018 6:03:11 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
4dd5766
Parents:
515c23df
git-author:
Piotr Rozyczko <rozyczko@…> (07/10/18 05:57:36)
git-committer:
Piotr Rozyczko <rozyczko@…> (07/10/18 06:03:11)
Message:

Delete open plots on data removal SASVIEW-958

File:
1 edited

Legend:

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

    r80468f6 rd9150d8  
    6767        # Buttons - data tab 
    6868        self.assertEqual(self.form.cmdLoad.text(), "Load data") 
    69         self.assertEqual(self.form.cmdDeleteData.text(), "Delete") 
     69        self.assertEqual(self.form.cmdDeleteData.text(), "Delete Data") 
    7070        self.assertEqual(self.form.cmdDeleteTheory.text(), "Delete") 
    7171        self.assertEqual(self.form.cmdFreeze.text(), "Freeze Theory") 
     
    819819        pass 
    820820 
    821     def notestDeleteItem(self): 
     821    def testDeleteItem(self): 
    822822        """ 
    823823        Delete selected item from data explorer 
     
    876876        self.assertEqual(self.form.model.rowCount(), 3) 
    877877 
     878    def testClosePlotsForItem(self): 
     879        """ 
     880        Delete selected item from data explorer should also delete corresponding plots 
     881        """ 
     882        # Mock the confirmation dialog with return=No 
     883        QMessageBox.question = MagicMock(return_value=QMessageBox.No) 
     884 
     885        loader = Loader() 
     886        manager = DataManager() 
     887        PlotHelper.clear() 
     888        self.form.enableGraphCombo(None) 
     889 
     890        # Make sure the controls are disabled 
     891        self.assertFalse(self.form.cbgraph.isEnabled()) 
     892        self.assertFalse(self.form.cmdAppend.isEnabled()) 
     893 
     894        # Populate the model 
     895        filename = ["cyl_400_20.txt"] 
     896        self.form.readData(filename) 
     897 
     898        # Mask plotting 
     899        self.form.parent.workspace = MagicMock() 
     900 
     901        # Call the plotting method 
     902        self.form.newPlot() 
     903 
     904        time.sleep(1) 
     905        QApplication.processEvents() 
     906 
     907        # The plot was registered 
     908        self.assertEqual(len(PlotHelper.currentPlots()), 1) 
     909        self.assertEqual(len(self.form.plot_widgets), 1) 
     910        self.assertEqual(list(self.form.plot_widgets.keys()), ['Graph3']) 
     911 
     912        # data index 
     913        model_item = self.form.model.item(0,0) 
     914 
     915        # Call the method 
     916        self.form.closePlotsForItem(model_item) 
     917 
     918        # See that no plot remained 
     919        self.assertEqual(len(PlotHelper.currentPlots()), 0) 
     920        self.assertEqual(len(self.form.plot_widgets), 0) 
     921 
    878922 
    879923if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.