Exemplo n.º 1
0
    def test_input_text_callback(self):
        """An input text runs callback with the result as argument"""
        callback_fn = Mock()
        inter = InputText("Content", callback_fn)
        inter.run_callback("Foo Bar Baz")

        callback_fn.assert_called_once_with("Foo Bar Baz")
Exemplo n.º 2
0
    def test_input_text_callback(self):
        """An input text runs callback with the result as argument"""
        callback_fn = Mock()
        inter = InputText("Content", callback_fn)
        inter.run_callback("Foo Bar Baz")

        callback_fn.assert_called_once_with("Foo Bar Baz")
Exemplo n.º 3
0
    def confirm_path(self, path_dir=""):
        """Confirm path dir"""

        if not path_dir:
            logger.debug("No installation path provided. Requesting one.")
            UI.display(
                InputText("Choose installation path:", self.confirm_path,
                          self.install_path))
            return

        logger.debug("Installation path provided. Checking if exists.")
        with suppress(FileNotFoundError):
            if os.listdir(path_dir):
                # we already told we were ok to overwrite as it was the previous install path
                if path_dir not in self._paths_to_clean:
                    if path_dir == "/":
                        logger.error(
                            "This doesn't seem wise. We won't let you shoot in your feet."
                        )
                        self.confirm_path()
                        return
                    self.install_path = path_dir  # we don't set it before to not repropose / as installation path
                    UI.display(
                        YesNo(
                            "{} isn't an empty directory, do you want to remove its content and install "
                            "there?".format(path_dir),
                            self.set_installdir_to_clean,
                            UI.return_main_screen))
                    return
        self.install_path = path_dir
        self.download_provider_page()
Exemplo n.º 4
0
    def test_input_text_with_default_input(self):
        """We can instantiate an input text with a default input"""
        inter = InputText("Content",
                          lambda: "",
                          default_input="This is a default input")

        self.assertEquals(inter.default_input, "This is a default input")
Exemplo n.º 5
0
    def test_input_text(self):
        """We can instantiate an input text"""
        inter = InputText("Content", lambda: "")

        self.assertEquals(inter.content, "Content")
        self.assertEquals(inter.default_input, "")