def test_get_algorithm_data(self):
     model = AlgorithmSelectorModel(None)
     names, descriptors = model.get_algorithm_data()
     self.assertTrue(isinstance(names, list))
     self.assertTrue(isinstance(descriptors, dict))
     self.assertTrue('Load' in names)
     self.assertTrue('Rebin' in names)
     self.assertTrue('Rebin' in descriptors['Transform'][AlgorithmSelectorModel.algorithm_key])
     self.assertTrue('Rebin' in descriptors['Transform']['Rebin'][AlgorithmSelectorModel.algorithm_key])
     counter = Counter(names)
     self.assertEqual(counter['Rebin'], 1)
     self.assertEqual(counter['DoStuff'], 1)
     self.assertEqual(mock_get_algorithm_descriptors.mock_calls[-1], call(False))
Exemplo n.º 2
0
    def test_sorting_of_algorithms(self):
        widget = AlgorithmSelectorWidget()
        model = AlgorithmSelectorModel(None)
        top_level = []

        widget._add_tree_items(top_level, model.get_algorithm_data()[1])

        self.assertEqual(top_level[0].text(0), "Data")
        self.assertEqual(top_level[1].text(0), "Sorted")
        self.assertEqual(top_level[2].text(0), "Stuff")
        self.assertEqual(top_level[3].text(0), "Transform")

        second_level = top_level[1].takeChildren()
        self.assertEqual(second_level[0].text(0), "ComesFirst v.1")
        self.assertEqual(second_level[1].text(0), "GoesSecond v.1")
    def test_sorting_of_algorithms(self):
        widget = AlgorithmSelectorWidget()
        model = AlgorithmSelectorModel(None)
        top_level = []

        widget._add_tree_items(top_level, model.get_algorithm_data()[1])

        self.assertEquals(top_level[0].text(0), "Data")
        self.assertEquals(top_level[1].text(0), "Sorted")
        self.assertEquals(top_level[2].text(0), "Stuff")
        self.assertEquals(top_level[3].text(0), "Transform")

        second_level = top_level[1].takeChildren()
        self.assertEquals(second_level[0].text(0), "ComesFirst v.1")
        self.assertEquals(second_level[1].text(0), "GoesSecond v.1")
Exemplo n.º 4
0
    def test_get_algorithm_data(self):
        model = AlgorithmSelectorModel(None)
        names, descriptors = model.get_algorithm_data()
        self.assertTrue(isinstance(names, list))
        self.assertTrue(isinstance(descriptors, dict))
        self.assertEqual(5, len(names))
        self.assertEqual('ComesFirst', names[0])
        self.assertEqual('DoStuff', names[1])
        self.assertEqual('GoesSecond', names[2])
        self.assertEqual('Load', names[3])
        self.assertEqual('Rebin', names[4])

        self.assertTrue('Rebin' in descriptors['Transform'][AlgorithmSelectorModel.algorithm_key])
        self.assertTrue('Rebin' in descriptors['Transform']['Rebin'][AlgorithmSelectorModel.algorithm_key])
        counter = Counter(names)
        self.assertEqual(counter['Rebin'], 1)
        self.assertEqual(counter['DoStuff'], 1)
        self.assertEqual(mock_get_algorithm_descriptors.mock_calls, [call(False), call(True)])
Exemplo n.º 5
0
 def test_include_hidden_algorithms(self):
     model = AlgorithmSelectorModel(None, include_hidden=True)
     model.get_algorithm_data()
     self.assertEqual(mock_get_algorithm_descriptors.mock_calls[-1],
                      call(True))
Exemplo n.º 6
0
 def test_include_hidden_algorithms(self):
     model = AlgorithmSelectorModel(None, include_hidden=True)
     model.get_algorithm_data()
     self.assertEqual(mock_get_algorithm_descriptors.mock_calls[-1], call(True))