Skip to content

Commit c74a84e

Browse files
committed
Assert status field and return execution_count
1 parent fb9f9fd commit c74a84e

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

crates/amalthea/src/fixtures/dummy_frontend.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,25 @@ impl DummyFrontend {
160160
Message::read_from_socket(&self.shell_socket).unwrap()
161161
}
162162

163-
/// Receive from Shell and assert ExecuteReply message
164-
pub fn recv_shell_execute_reply(&self) -> Status {
163+
/// Receive from Shell and assert `ExecuteReply` message.
164+
/// Returns `execution_count`.
165+
pub fn recv_shell_execute_reply(&self) -> u32 {
165166
let msg = self.recv_shell();
166167

167168
assert_match!(msg, Message::ExecuteReply(data) => {
168-
data.content.status
169+
assert_eq!(data.content.status, Status::Ok);
170+
data.content.execution_count
169171
})
170172
}
171173

172-
/// Receive from Shell and assert ExecuteReplyException message
173-
pub fn recv_shell_execute_reply_exception(&self) -> Status {
174-
let msg = Message::read_from_socket(&self.shell_socket).unwrap();
174+
/// Receive from Shell and assert `ExecuteReplyException` message.
175+
/// Returns `execution_count`.
176+
pub fn recv_shell_execute_reply_exception(&self) -> u32 {
177+
let msg = self.recv_shell();
175178

176179
assert_match!(msg, Message::ExecuteReplyException(data) => {
177-
data.content.status
180+
assert_eq!(data.content.status, Status::Error);
181+
data.content.execution_count
178182
})
179183
}
180184

crates/ark/tests/kernel.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use amalthea::wire::jupyter_message::Message;
2-
use amalthea::wire::jupyter_message::Status;
32
use amalthea::wire::kernel_info_request::KernelInfoRequest;
43
use ark::fixtures::DummyArkFrontend;
54
use stdext::assert_match;
@@ -25,12 +24,13 @@ fn test_execute_request() {
2524
frontend.send_execute_request("42");
2625
frontend.recv_iopub_busy();
2726

28-
assert_eq!(frontend.recv_iopub_execute_input().code, "42");
27+
let input = frontend.recv_iopub_execute_input();
28+
assert_eq!(input.code, "42");
2929
assert_eq!(frontend.recv_iopub_execute_result(), "[1] 42");
3030

3131
frontend.recv_iopub_idle();
3232

33-
assert_eq!(frontend.recv_shell_execute_reply(), Status::Ok);
33+
assert_eq!(frontend.recv_shell_execute_reply(), input.execution_count)
3434
}
3535

3636
#[test]
@@ -40,10 +40,14 @@ fn test_execute_request_error() {
4040
frontend.send_execute_request("stop('foobar')");
4141
frontend.recv_iopub_busy();
4242

43-
assert_eq!(frontend.recv_iopub_execute_input().code, "stop('foobar')");
43+
let input = frontend.recv_iopub_execute_input();
44+
assert_eq!(input.code, "stop('foobar')");
4445
assert!(frontend.recv_iopub_execute_error().contains("foobar"));
4546

4647
frontend.recv_iopub_idle();
4748

48-
assert_eq!(frontend.recv_shell_execute_reply_exception(), Status::Error);
49+
assert_eq!(
50+
frontend.recv_shell_execute_reply_exception(),
51+
input.execution_count
52+
);
4953
}

0 commit comments

Comments
 (0)