source: sasview/src/sas/qtgui/UnitTesting/PlotHelperTest.py @ 161713c

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 161713c was 8cb6cd6, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago

Plot handler prototype + append plot functionality

  • Property mode set to 100755
File size: 1.6 KB
RevLine 
[8cb6cd6]1import unittest
2
3# Tested module
4import PlotHelper
5
6class PlotHelperTest(unittest.TestCase):
7    '''Test the Plot helper functions'''
8    def setUp(self):
9        '''Empty'''
10        pass
11
12    def tearDown(self):
13        '''Empty'''
14        pass
15
16    def testDefaults(self):
17        """ default method variables values """
18        self.assertIsInstance(PlotHelper._plots, dict)
19        self.assertEqual(PlotHelper._plots, {})
20        self.assertEqual(PlotHelper._plot_id, 0)
21
22    def testFunctions(self):
23        """ Adding a plot """
24        plot = "I am a plot. Really."
25        PlotHelper.addPlot(plot)
26        plot_id = PlotHelper.idOfPlot(plot)
27
28        # We can't guarantee unique values for plot_id, as
29        # the tests are executed in random order, so just
30        # make sure we get consecutive values for 2 plots
31        plot2 = "I am also a plot."
32        PlotHelper.addPlot(plot2)
33        plot_id_2 = PlotHelper.idOfPlot(plot2)
34        self.assertEqual(plot_id_2 - plot_id, 1)
35
36        # Other properties
37        self.assertEqual(PlotHelper.currentPlots(), [plot_id, plot_id_2])
38        self.assertEqual(PlotHelper.plotById(plot_id), plot)
39        self.assertEqual(PlotHelper.plotById(plot_id_2), plot2)
40
41        # Delete a graph
42        PlotHelper.deletePlot(plot_id)
43        self.assertEqual(PlotHelper.currentPlots(), [plot_id_2])
44
45        # Add another graph to see the counter
46        plot3 = "Just another plot. Move along."
47        PlotHelper.addPlot(plot3)
48        self.assertEqual(PlotHelper.idOfPlot(plot3), plot_id_2 + 1)
49
50if __name__ == "__main__":
51    unittest.main()
Note: See TracBrowser for help on using the repository browser.