Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/amalthea/src/fixtures/dummy_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl DummyFrontend {

/// Receive from Shell and assert `ExecuteReply` message.
/// Returns `execution_count`.
#[track_caller]
pub fn recv_shell_execute_reply(&self) -> u32 {
let msg = self.recv_shell();

Expand All @@ -281,6 +282,7 @@ impl DummyFrontend {

/// Receive from Shell and assert `ExecuteReplyException` message.
/// Returns `execution_count`.
#[track_caller]
pub fn recv_shell_execute_reply_exception(&self) -> u32 {
let msg = self.recv_shell();

Expand All @@ -291,6 +293,7 @@ impl DummyFrontend {
}

/// Receive from IOPub and assert Busy message
#[track_caller]
pub fn recv_iopub_busy(&self) -> () {
let msg = self.recv_iopub();

Expand All @@ -300,6 +303,7 @@ impl DummyFrontend {
}

/// Receive from IOPub and assert Idle message
#[track_caller]
pub fn recv_iopub_idle(&self) -> () {
let msg = self.recv_iopub();

Expand All @@ -309,6 +313,7 @@ impl DummyFrontend {
}

/// Receive from IOPub and assert ExecuteInput message
#[track_caller]
pub fn recv_iopub_execute_input(&self) -> ExecuteInput {
let msg = self.recv_iopub();

Expand All @@ -319,6 +324,7 @@ impl DummyFrontend {

/// Receive from IOPub and assert ExecuteResult message. Returns compulsory
/// `plain/text` result.
#[track_caller]
pub fn recv_iopub_execute_result(&self) -> String {
let msg = self.recv_iopub();

Expand All @@ -331,24 +337,29 @@ impl DummyFrontend {
})
}

#[track_caller]
pub fn recv_iopub_display_data(&self) {
let msg = self.recv_iopub();
assert_matches!(msg, Message::DisplayData(_))
}

#[track_caller]
pub fn recv_iopub_update_display_data(&self) {
let msg = self.recv_iopub();
assert_matches!(msg, Message::UpdateDisplayData(_))
}

#[track_caller]
pub fn recv_iopub_stream_stdout(&self, expect: &str) {
self.recv_iopub_stream(expect, Stream::Stdout)
}

#[track_caller]
pub fn recv_iopub_stream_stderr(&self, expect: &str) {
self.recv_iopub_stream(expect, Stream::Stderr)
}

#[track_caller]
pub fn recv_iopub_comm_close(&self) -> String {
let msg = self.recv_iopub();

Expand All @@ -362,6 +373,7 @@ impl DummyFrontend {
/// Stdout and Stderr Stream messages are buffered, so to reliably test against them
/// we have to collect the messages in batches on the receiving end and compare against
/// an expected message.
#[track_caller]
fn recv_iopub_stream(&self, expect: &str, stream: Stream) {
let mut out = String::new();

Expand Down Expand Up @@ -395,6 +407,7 @@ impl DummyFrontend {

/// Receive from IOPub and assert ExecuteResult message. Returns compulsory
/// `evalue` field.
#[track_caller]
pub fn recv_iopub_execute_error(&self) -> String {
let msg = self.recv_iopub();

Expand All @@ -405,6 +418,7 @@ impl DummyFrontend {

/// Receive from Stdin and assert `InputRequest` message.
/// Returns the `prompt`.
#[track_caller]
pub fn recv_stdin_input_request(&self) -> String {
let msg = self.recv_stdin();

Expand All @@ -414,23 +428,27 @@ impl DummyFrontend {
}

/// Send back an `InputReply` to an `InputRequest` over Stdin
#[track_caller]
pub fn send_stdin_input_reply(&self, value: String) {
self.send_stdin(InputReply { value })
}

/// Receives a (raw) message from the heartbeat socket
#[track_caller]
pub fn recv_heartbeat(&self) -> zmq::Message {
let mut msg = zmq::Message::new();
self.heartbeat_socket.recv(&mut msg).unwrap();
msg
}

/// Sends a (raw) message to the heartbeat socket
#[track_caller]
pub fn send_heartbeat(&self, msg: zmq::Message) {
self.heartbeat_socket.send(msg).unwrap();
}

/// Asserts that no socket has incoming data
#[track_caller]
pub fn assert_no_incoming(&mut self) {
let mut has_incoming = false;

Expand Down