Beispiel #1
0
        public async Task Fails_to_install_kernels_when_jupyter_is_not_installed()
        {
            var root      = CreateDirectory();
            var kernelDir = new DirectoryInfo(Path.Combine(root.FullName, "source"));

            kernelDir.Create();
            var destination = new DirectoryInfo(Path.Combine(root.FullName, "destination"));

            UnpackKernelsSpecTo(kernelDir);

            var jupyterKernelSpecModuleSimulator = new JupyterKernelSpecModuleSimulator(false, destination, new Win32Exception("")
            {
                Source = typeof(System.Diagnostics.Process).FullName
            });

            var defaultPath         = jupyterKernelSpecModuleSimulator.GetDefaultKernelSpecDirectory();
            var kernelSpecInstaller = new JupyterKernelSpecInstaller(Console, jupyterKernelSpecModuleSimulator);
            var result = await kernelSpecInstaller.TryInstallKernelAsync(kernelDir);

            var error = Console.Error.ToString();

            using var scope = new AssertionScope();
            result.Should().BeFalse();
            error.Should().Match($"*The kernelspec path {defaultPath.FullName} does not exist.*");
        }
Beispiel #2
0
        public async Task Uses_default_kernel_paths_when_kernelspec_module_is_not_on_path_and_jupyter_is_installed()
        {
            var root      = CreateDirectory();
            var kernelDir = new DirectoryInfo(Path.Combine(root.FullName, "source"));

            kernelDir.Create();
            var destination = new DirectoryInfo(Path.Combine(root.FullName, "destination"));

            destination.Create();

            UnpackKernelsSpecTo(kernelDir);

            var jupyterKernelSpecModuleSimulator = new JupyterKernelSpecModuleSimulator(false, destination, new Win32Exception("")
            {
                Source = typeof(System.Diagnostics.Process).FullName
            });

            var kernelSpecInstaller = new JupyterKernelSpecInstaller(Console, jupyterKernelSpecModuleSimulator);
            var result = await kernelSpecInstaller.TryInstallKernelAsync(kernelDir);

            var output = Console.Out.ToString();

            using var scope = new AssertionScope();
            result.Should().BeTrue();
            output.Should().Match($"Installing using path { destination.FullName}.*");
        }
Beispiel #3
0
        public async Task Appends_http_port_range_arguments()
        {
            var console             = new TestConsole();
            var kernelSpecModule    = new JupyterKernelSpecModuleSimulator(true);
            var kernelSpecInstaller = new JupyterKernelSpecInstaller(console, kernelSpecModule);
            var jupyterCommandLine  = new JupyterInstallCommand(console, kernelSpecInstaller, new PortRange(100, 400));

            await jupyterCommandLine.InvokeAsync();

            kernelSpecModule.InstalledKernelSpecs
            .Should()
            .HaveCount(3)
            .And
            .Match(s => s.All(k => k.Contains("--http-port-range")));
        }
Beispiel #4
0
        public async Task Prints_to_console_when_kernel_installation_succeeded()
        {
            var console             = new TestConsole();
            var kernelSpecModule    = new JupyterKernelSpecModuleSimulator(true);
            var kernelSpecInstaller = new JupyterKernelSpecInstaller(console, kernelSpecModule);
            var jupyterCommandLine  = new JupyterInstallCommand(console, kernelSpecInstaller);

            await jupyterCommandLine.InvokeAsync();

            var consoleOut = console.Out.ToString();

            using var scope = new AssertionScope();

            consoleOut.Should().Contain("Installed \".NET (F#)\" kernel.");
            consoleOut.Should().Contain("Installed \".NET (C#)\" kernel.");
        }
        public async Task kernel_spec_is_not_broken(string displayName)
        {
            var _configuration = new Configuration()
                                 .UsingExtension($"kernelspec_{displayName.Replace(".", "_").Replace(" ", "_")}.txt")
                                 .SetInteractive(Debugger.IsAttached);

            var console             = new TestConsole();
            var kernelSpecModule    = new JupyterKernelSpecModuleSimulator(true);
            var kernelSpecInstaller = new JupyterKernelSpecInstaller(console, kernelSpecModule);
            var jupyterCommandLine  = new JupyterInstallCommand(console, kernelSpecInstaller, new HttpPortRange(100, 400));

            await jupyterCommandLine.InvokeAsync();

            var kernelSpec = kernelSpecModule.InstalledKernelSpecs.Single(k => k.Contains(displayName));

            this.Assent(kernelSpec, _configuration);
        }
Beispiel #6
0
        public async Task Returns_error_when_jupyter_paths_could_not_be_obtained()
        {
            var console             = new TestConsole();
            var kernelSpecModule    = new JupyterKernelSpecModuleSimulator(false);
            var kernelSpecInstaller = new JupyterKernelSpecInstaller(console, kernelSpecModule);
            var installCommand      = new JupyterInstallCommand(
                console,
                kernelSpecInstaller);

            await installCommand.InvokeAsync();

            var consoleError = console.Error.ToString();

            using var scope = new AssertionScope();
            consoleError.Should().Contain("Failed to install \".NET (F#)\" kernel.");
            consoleError.Should().Contain("Failed to install \".NET (C#)\" kernel.");
            consoleError.Should().Contain("Failed to install \".NET (PowerShell)\" kernel.");
        }
Beispiel #7
0
        public async Task Returns_success_output_when_kernel_installation_succeeded()
        {
            var kernelDir = CreateDirectory();

            UnpackKernelsSpecTo(kernelDir);

            var jupyterKernelSpecModuleSimulator = new JupyterKernelSpecModuleSimulator(true);
            var kernelSpecInstaller = new JupyterKernelSpecInstaller(Console, jupyterKernelSpecModuleSimulator);


            var result = await kernelSpecInstaller.TryInstallKernelAsync(kernelDir);

            var output = Console.Out.ToString();

            using var scope = new AssertionScope();
            result.Should().BeTrue();
            _kernelInstallations.Add(new DirectoryInfo(kernelDir.Name));
            output.Should().MatchEquivalentOf("*Installing using jupyter kernelspec module.*");
            output.Should().MatchEquivalentOf("*Installed * kernel.");
        }