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}.*"); }
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.*"); }
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."); }