def test_create_single_categorised_figure(self,mock_figure_class):
     mock_figures = [mock.Mock()]
     mock_figure_class.side_effect = mock_figures
     category = '1d'
     # The following line is equivalent to applying the decorator setcategory with the parameter category
     # to function GlobalFigureManager.get_active_figure
     categorised_get_active_figure = set_category(category)(GlobalFigureManager.get_active_figure)
     fig = categorised_get_active_figure()
     self.assertTrue(fig == mock_figures[0]) # Assert Figure object came from right place
     self.assertTrue(GlobalFigureManager.get_category(1) == category)
     self.assertTrue(GlobalFigureManager.get_active_figure() == mock_figures[0]) # Check that it is set as the active figure
    def test_create_categorised_figure_then_uncategorised_figure(self,mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        category = '1d'
        categorised_get_active_figure = set_category(category)(GlobalFigureManager.get_active_figure)

        fig1 = categorised_get_active_figure()
        fig2 = GlobalFigureManager.get_figure_number()
        fig1_number = GlobalFigureManager.number_of_figure(fig1)
        fig2_number = GlobalFigureManager.number_of_figure(fig2)
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig2)
        self.assertTrue(GlobalFigureManager.get_category(fig1_number) == category)
        self.assertRaises(KeyError, GlobalFigureManager.get_category, fig2_number)
        self.assertTrue( fig1_number == 1 and fig2_number == 2)
Esempio n. 3
0
 def test_create_single_categorised_figure(self, mock_figure_class):
     mock_figures = [mock.Mock()]
     mock_figure_class.side_effect = mock_figures
     category = '1d'
     # The following line is equivalent to applying the decorator setcategory with the parameter category
     # to function GlobalFigureManager.get_active_figure
     categorised_get_active_figure = set_category(category)(
         GlobalFigureManager.get_active_figure)
     fig = categorised_get_active_figure()
     self.assertTrue(
         fig ==
         mock_figures[0])  # Assert Figure object came from right place
     self.assertTrue(GlobalFigureManager.get_category(1) == category)
     self.assertTrue(
         GlobalFigureManager.get_active_figure() ==
         mock_figures[0])  # Check that it is set as the active figure
Esempio n. 4
0
    def test_create_categorised_figure_then_uncategorised_figure(
            self, mock_figure_class):
        mock_figures = [mock.Mock(), mock.Mock()]
        mock_figure_class.side_effect = mock_figures
        category = '1d'
        categorised_get_active_figure = set_category(category)(
            GlobalFigureManager.get_active_figure)

        fig1 = categorised_get_active_figure()
        fig2 = GlobalFigureManager.get_figure_number()
        fig1_number = GlobalFigureManager.number_of_figure(fig1)
        fig2_number = GlobalFigureManager.number_of_figure(fig2)
        self.assertTrue(GlobalFigureManager.get_active_figure() == fig2)
        self.assertTrue(
            GlobalFigureManager.get_category(fig1_number) == category)
        self.assertRaises(KeyError, GlobalFigureManager.get_category,
                          fig2_number)
        self.assertTrue(fig1_number == 1 and fig2_number == 2)