def test_darwin(self):
        MultipassCommand.setup_multipass(platform="darwin", echoer=self.echoer_mock)

        self.check_call_mock.assert_called_once_with(
            ["brew", "cask", "install", "multipass"]
        )
        self.echoer_mock.wrapped.assert_called_once_with("Waiting for multipass...")
    def test_linux(self):
        self.fake_snapd.snaps_result = [
            dict(name="multipass", channel="beta", revision="10")
        ]
        self.fake_snapd.find_result = [
            dict(multipass=dict(
                channels={"latest/beta": dict(confinement="classic")}))
        ]
        MultipassCommand.setup_multipass(platform="linux",
                                         echoer=self.echoer_mock)

        self.echoer_mock.wrapped.assert_called_once_with(
            "Waiting for multipass...")
Beispiel #3
0
    def test_ensure_multipass_raises(self, monkeypatch, platform,
                                     prompt_installable, snap_which):
        def which_effect(command: str):
            if command == "snap" and snap_which:
                return ["snap"]

            return None

        monkeypatch.setattr(shutil, "which", which_effect)

        with pytest.raises(errors.ProviderNotFound) as error:
            MultipassCommand.ensure_multipass(platform)
            assert error.prompt_installable is prompt_installable
    def setUp(self):
        super().setUp()

        patcher = mock.patch('subprocess.check_call')
        self.check_call_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('subprocess.check_output')
        self.check_output_mock = patcher.start()
        self.addCleanup(patcher.stop)

        self.multipass_command = MultipassCommand()
        self.instance_name = 'stub-instance'
    def setUp(self):
        super().setUp()

        patcher = mock.patch("subprocess.check_call")
        self.check_call_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch("subprocess.check_output")
        self.check_output_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch("subprocess.Popen")
        self.popen_mock = patcher.start()
        self.popen_mock().communicate.return_value = (b"", b"error")
        self.popen_mock().returncode = 0
        self.addCleanup(patcher.stop)

        self.multipass_command = MultipassCommand()
        self.instance_name = "stub-instance"
    def test_ensure_multipass_on_command_found(self):
        self.which_mock.return_value = ["multipass"]

        MultipassCommand.ensure_multipass(platform="linux")