performJupyterRequest preforms a request and awaits a reply on the shell channel. Additionally all messages on the IOPub channel between the opening 'busy' messages and closing 'idle' message are captured and returned. The request will timeout after the given timeout delay. Upon error or timeout, re
(t *testing.T, request ComposedMsg, timeout time.Duration)
| 463 | // IOPub channel between the opening 'busy' messages and closing 'idle' message are captured and returned. The request |
| 464 | // will timeout after the given timeout delay. Upon error or timeout, request will Fail the test. |
| 465 | func (client *testJupyterClient) performJupyterRequest(t *testing.T, request ComposedMsg, timeout time.Duration) (ComposedMsg, []ComposedMsg) { |
| 466 | t.Helper() |
| 467 | |
| 468 | client.sendShellRequest(t, request) |
| 469 | reply := client.recvShellReply(t, timeout) |
| 470 | |
| 471 | // Read the expected 'busy' message and ensure it is in fact, a 'busy' message. |
| 472 | subMsg := client.recvIOSub(t, 1*time.Second) |
| 473 | assertMsgTypeEquals(t, subMsg, "status") |
| 474 | |
| 475 | subData := getMsgContentAsJSONObject(t, subMsg) |
| 476 | execState := getString(t, "content", subData, "execution_state") |
| 477 | |
| 478 | if execState != kernelBusy { |
| 479 | t.Fatalf("\t%s Expected a 'busy' status message but got '%s'", failure, execState) |
| 480 | } |
| 481 | |
| 482 | var pub []ComposedMsg |
| 483 | |
| 484 | // Read messages from the IOPub channel until an 'idle' message is received. |
| 485 | for { |
| 486 | subMsg = client.recvIOSub(t, 100*time.Millisecond) |
| 487 | |
| 488 | // If the message is a 'status' message, ensure it is an 'idle' status. |
| 489 | if subMsg.Header.MsgType == "status" { |
| 490 | subData = getMsgContentAsJSONObject(t, subMsg) |
| 491 | execState = getString(t, "content", subData, "execution_state") |
| 492 | |
| 493 | if execState != kernelIdle { |
| 494 | t.Fatalf("\t%s Expected a 'idle' status message but got '%s'", failure, execState) |
| 495 | } |
| 496 | |
| 497 | // Break from the loop as we don't expect any other IOPub messages after the 'idle'. |
| 498 | break |
| 499 | } |
| 500 | |
| 501 | // Add the message to the pub collection. |
| 502 | pub = append(pub, subMsg) |
| 503 | } |
| 504 | |
| 505 | return reply, pub |
| 506 | } |
| 507 | |
| 508 | // executeCode creates an execute request for the given code and preforms the request. It returns the content of the |
| 509 | // reply as well as all of the messages captured from the IOPub channel during the execution. |
no test coverage detected