Search in sources :

Example 16 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class ClasspathAddRepoMagicCommandTest method addExternalRepo.

@Test
public void addExternalRepo() {
    // given
    String allCode = CLASSPATH_CONFIG_RESOLVER + " " + "externalRepo http://someExternalRepo";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(ADDED_NEW_REPO + "externalRepo");
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 17 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class TimeCellModeMagicCommandTest method timeInCellMode.

@Test
public void timeInCellMode() {
    // given
    String allCode = "" + "%%time \n" + "a = [10,20,30,40,50]; \n" + "a= a.sum(); \n" + "a*10;";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains("CPU times:");
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 18 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class KernelExecutionTest method shouldImportDemoClassByMagicCommand.

@Test
public void shouldImportDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar();
    // when
    Code code = CodeFactory.create(IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyImportedDemoClassByMagicCommand();
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test)

Example 19 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class KernelExecutionTest method shouldImportDemoClassWithWildcardByMagicCommand.

@Test
public void shouldImportDemoClassWithWildcardByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar();
    String allCode = IMPORT + " " + path.substring(0, path.lastIndexOf(".")) + ".*";
    // when
    Code code = CodeFactory.create(allCode, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyImportedDemoClassByMagicCommand();
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test)

Example 20 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class KernelExecutionTest method verifyLoadedMagicCommand.

private void verifyLoadedMagicCommand() throws InterruptedException {
    String allCode = "%showEnvs";
    Code code = CodeFactory.create(allCode, new Message(), getKernel());
    code.execute(getKernel(), 3);
    List<Message> std = waitForStdouts(getKernelSocketsService().getKernelSockets());
    String text = (String) std.get(2).getContent().get("text");
    assertThat(text).contains("PATH");
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code)

Aggregations

Code (com.twosigma.beakerx.kernel.Code)55 Message (com.twosigma.beakerx.message.Message)54 Test (org.junit.Test)47 KernelTest (com.twosigma.beakerx.KernelTest)33 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)29 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)16 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)16 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)9 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)9 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)9 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)7 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)7 ClasspathAddMvnMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand)4 ClasspathResetMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand)4 ImportPath (com.twosigma.beakerx.kernel.ImportPath)3 PathToJar (com.twosigma.beakerx.kernel.PathToJar)2 MagicCommand (com.twosigma.beakerx.kernel.magic.command.MagicCommand)2 ClassPathAddMvnCellMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClassPathAddMvnCellMagicCommand)2 EvaluatorResultTestWatcher (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher)1