def test_construction_with_functions_and_default_sets_placeholder_to_default(self):
        view = AddFunctionDialogView(function_names=self.TEST_FUNCTION_NAMES,
                                     default_function_name=self.TEST_FUNCTION_NAMES[1])

        self.assertTrue(view is not None)
        self.assertEqual(len(self.TEST_FUNCTION_NAMES), view.ui.functionBox.count())
        self.assertEqual(self.TEST_FUNCTION_NAMES[1],
                         view.ui.functionBox.lineEdit().placeholderText())
    def test_pressing_return_in_box_activates_completer(self):
        view = AddFunctionDialogView(function_names=self.TEST_FUNCTION_NAMES)

        QTest.keyPress(view.ui.functionBox, Qt.Key_F)
        QTest.keyPress(view.ui.functionBox, Qt.Key_U)
        QTest.keyPress(view.ui.functionBox, Qt.Key_N)
        QTest.keyPress(view.ui.functionBox, Qt.Key_C)
        QTest.keyPress(view.ui.functionBox, Qt.Key_1)
        QTest.keyPress(view.ui.functionBox, Qt.Key_Return)

        self.assertEqual(self.TEST_FUNCTION_NAMES[0], view.ui.functionBox.currentText())
    def test_construction_with_functions_gives_list_of_same_length(self):
        view = AddFunctionDialogView(function_names=self.TEST_FUNCTION_NAMES)

        self.assertTrue(view is not None)
        self.assertEqual(len(self.TEST_FUNCTION_NAMES), view.ui.functionBox.count())
    def test_construction_with_no_functions_gives_empty_list(self):
        view = AddFunctionDialogView()

        self.assertTrue(view is not None)
        self.assertEqual(0, view.ui.functionBox.count())
 def test_checkbox_not_exists_if_not_requested(self):
     view = AddFunctionDialogView()
     self.assertFalse(hasattr(view, '_default_checkbox'))
 def test_checkbox_exists_if_requested(self):
     view = AddFunctionDialogView(default_checkbox=True)
     self.assertTrue(hasattr(view, '_default_checkbox'))