@@ -9,20 +9,21 @@ class TestOutputProcessor(OutputProcessor):
99
1010 settings = {}
1111
12-
13- def test_instantiation ():
14- op = OutputProcessor ()
15-
1612def create_incoming_message (cell_id ):
1713 msg_id = str (uuid4 ())
18- header = {"msg_id" : msg_id , "msg_type" : "shell " }
14+ header = {"msg_id" : msg_id , "msg_type" : "execute_request " }
1915 parent_header = {}
2016 metadata = {"cellId" : cell_id }
2117 msg = [json .dumps (item ) for item in [header , parent_header , metadata ]]
2218 return msg_id , msg
2319
24- def test_incoming_message ():
20+ def test_instantiation ():
21+ """Test instantiation of the output processor."""
22+ op = OutputProcessor ()
23+ assert isinstance (op , OutputProcessor )
2524
25+ def test_incoming_message ():
26+ """Test incoming message processing."""
2627 with TemporaryDirectory () as td :
2728 op = TestOutputProcessor ()
2829 om = OutputsManager ()
@@ -34,18 +35,19 @@ def test_incoming_message():
3435 op .process_incoming_message ('shell' , msg )
3536 assert op .get_cell_id (msg_id ) == cell_id
3637 assert op .get_msg_id (cell_id ) == msg_id
37- # # Clear the cell_id
38- # op.clear(cell_id)
39- # assert op.get_cell_id(msg_id) is None
40- # assert op.get_msg_id(cell_id) is None
41- # # Simulate the running of a cell
42- # cell_id = str(uuid4())
43- # msg_id, msg = create_incoming_message(cell_id)
44- # op.process_incoming_message('shell', msg)
45- # assert op.get_cell_id(msg_id) == cell_id
46- # assert op.get_msg_id(cell_id) == msg_id
38+ # Clear the cell_id
39+ op .clear (cell_id )
40+ assert op .get_cell_id (msg_id ) is None
41+ assert op .get_msg_id (cell_id ) is None
42+ # Simulate the running of a cell
43+ cell_id = str (uuid4 ())
44+ msg_id , msg = create_incoming_message (cell_id )
45+ op .process_incoming_message ('shell' , msg )
46+ assert op .get_cell_id (msg_id ) == cell_id
47+ assert op .get_msg_id (cell_id ) == msg_id
4748 # # Run it again without clearing to ensure it self clears
48- # cell_id = str(uuid4())
49- # msg_id, msg = create_incoming_message(cell_id)
50- # assert op.get_cell_id(msg_id) == cell_id
51- # assert op.get_msg_id(cell_id) == msg_id
49+ cell_id = str (uuid4 ())
50+ msg_id , msg = create_incoming_message (cell_id )
51+ op .process_incoming_message ('shell' , msg )
52+ assert op .get_cell_id (msg_id ) == cell_id
53+ assert op .get_msg_id (cell_id ) == msg_id
0 commit comments