public void HasExecuteError_Abort() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); dynamic content = new System.Dynamic.ExpandoObject(); // Abort is considered deprecated as of Jupyter 5.1, but we are still going to ensure we handle it, in // case there is an older kernel we need to interact with. content.status = ExecuteStatus.Abort; client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = true, ExecutionIndex = 1, Request = new Message(null), Response = new List <Message>() { new Message() { Content = content } } }); Assert.IsTrue(client.HasExecuteError()); }
public void HasExecuteError_NonStandardContent() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); // The check expects an element named "status". We are going to have something different, // and even though it's set to the error of a value, it's not actually a status error so // the message should be flagged as okay. dynamic content = new System.Dynamic.ExpandoObject(); content.test = ExecuteStatus.Error; client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = true, ExecutionIndex = 1, Request = new Message(null), Response = new List <Message>() { new Message() { Content = content } } }); Assert.IsFalse(client.HasExecuteError()); }
public void HasExecuteError_Empty() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); Assert.IsFalse(client.HasExecuteError()); }
public void ClearExecuteLog() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); client.StartChannels(); client.Execute("test"); client.ClearExecuteLog(); Assert.IsFalse(client.HasPendingExecute()); Assert.AreEqual(0, client.GetPendingExecuteCount()); }
public void TrackExecuteRequests() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); client.StartChannels(); client.Execute("test"); Assert.IsTrue(client.HasPendingExecute()); Assert.AreEqual(1, client.GetPendingExecuteCount()); client.Execute("test"); Assert.IsTrue(client.HasPendingExecute()); Assert.AreEqual(2, client.GetPendingExecuteCount()); }
public void GetExecuteErrors_AbandonedCode() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = false, Abandoned = true, ExecutionIndex = -1, Request = new Message(null) }); Assert.AreEqual(1, client.GetExecuteErrors().Count); Assert.AreEqual(KernelClient.ABANDONED_CODE_ERROR_MESSAGE, client.GetExecuteErrors().First()); }
public void GetExecuteErrors_None() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = true, ExecutionIndex = 1, Request = new Message(null), Response = new List <Message>() { GetErrorMessage(), GetErrorMessage() } }); Assert.AreEqual(0, client.GetExecuteErrors().Count); }
public void HasExecuteError_AbandonedCode() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = false, Abandoned = true, ExecutionIndex = -1, Request = new Message(null) }); // If an execution request is flagged as abandoned, we consider that an error // situation and will stop. Assert.IsTrue(client.HasExecuteError()); }
public void HasExecuteError_MixedStatuses() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = true, ExecutionIndex = 1, Request = new Message(null), Response = new List <Message>() { GetSuccessMessage(), GetErrorMessage(), GetErrorMessage(), GetSuccessMessage() } }); Assert.IsTrue(client.HasExecuteError()); }
public void GetExecuteErrors_MultipleWithEmpty() { var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object); Assert.IsFalse(client.HasExecuteError()); client.StartChannels(); client.ExecuteLog.Add("1", new ExecutionEntry() { Complete = true, ExecutionIndex = 1, Request = new Message(null), Response = new List <Message>() { GetErrorMessage("Error message 1"), GetErrorMessage(), GetErrorMessage("Error message 2") } }); Assert.AreEqual(2, client.GetExecuteErrors().Count); Assert.AreEqual("TestError: Error message 1", client.GetExecuteErrors().First()); Assert.AreEqual("TestError: Error message 2", client.GetExecuteErrors().Last()); }
public void IsAlive() { // I don't love that we have to change the kernel manager's status, but the underlying checks // for the client rely on that status being set appropriately. KernelManagerMock.SetupGet(x => x.IsAlive).Returns(false); KernelManagerMock.SetupGet(x => x.HasKernel).Returns(false); var client = new KernelClient(KernelManagerMock.Object, ChannelFactoryMock.Object, false); Assert.IsFalse(client.IsAlive); KernelManagerMock.SetupGet(x => x.IsAlive).Returns(true); KernelManagerMock.SetupGet(x => x.HasKernel).Returns(true); client.StartChannels(); Assert.IsTrue(client.IsAlive); KernelManagerMock.SetupGet(x => x.IsAlive).Returns(false); KernelManagerMock.SetupGet(x => x.HasKernel).Returns(false); client.StopChannels(); Assert.IsFalse(client.IsAlive); }