def test_create_single_unclassified_plot_success(self, mock_figure_class):
        mock_figures = [mock.Mock()]
        mock_figure_class.side_effect = mock_figures

        GlobalFigureManager.get_figure_number()
        self.assertTrue(1 in GlobalFigureManager.all_figure_numbers()) #Check that a new figure with number=1 was created
        self.assertRaises(KeyError, GlobalFigureManager.get_category, 1) #Check that figure has no category
        self.assertTrue(GlobalFigureManager.get_active_figure() == mock_figures[0]) # Check that it is set as the active figure
    def test_create_multiple_unclassified_figures(self, mock_figure_class):
        """Test that n calls to GlobalFigureManager create n unclassified _figures numbered 1 to n """
        n = 10  # number of unclassfied _figures to be created
        mock_figures = [mock.Mock() for i in range(n)]
        mock_figure_class.side_effect = mock_figures

        for i in range(n):
            GlobalFigureManager.get_figure_number() # Create a new figure
        for i in range(1, n+1):
            self.assertTrue(i in GlobalFigureManager.all_figure_numbers()) #Check that a new figure with number=i was created
            self.assertRaises(KeyError, GlobalFigureManager.get_category, i) #Check that figure has no category
    def test_create_single_unclassified_plot_success(self, mock_figure_class):
        mock_figures = [mock.Mock()]
        mock_figure_class.side_effect = mock_figures

        GlobalFigureManager.get_figure_number()
        self.assertTrue(1 in GlobalFigureManager.all_figure_numbers()
                        )  #Check that a new figure with number=1 was created
        self.assertRaises(KeyError, GlobalFigureManager.get_category,
                          1)  #Check that figure has no category
        self.assertTrue(
            GlobalFigureManager.get_active_figure() ==
            mock_figures[0])  # Check that it is set as the active figure
    def test_create_multiple_unclassified_figures(self, mock_figure_class):
        """Test that n calls to GlobalFigureManager create n unclassified _figures numbered 1 to n """
        n = 10  # number of unclassfied _figures to be created
        mock_figures = [mock.Mock() for i in range(n)]
        mock_figure_class.side_effect = mock_figures

        for i in range(n):
            GlobalFigureManager.get_figure_number()  # Create a new figure
        for i in range(1, n + 1):
            self.assertTrue(i in GlobalFigureManager.all_figure_numbers(
            ))  #Check that a new figure with number=i was created
            self.assertRaises(KeyError, GlobalFigureManager.get_category,
                              i)  #Check that figure has no category
    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)
    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)