def test_statement_from_json_no_output(): session_id = 5 statement_json = {"id": 10, "state": "running", "output": None} expected = Statement( session_id, statement_id=10, state=StatementState.RUNNING, output=None ) assert Statement.from_json(session_id, statement_json) == expected
def test_statement_from_json_no_output(): session_id = 5 statement_json = {'id': 10, 'state': 'running', 'output': None} expected = Statement(session_id, statement_id=10, state=StatementState.RUNNING, output=None) assert Statement.from_json(session_id, statement_json) == expected
def test_statement_from_json_with_output(mocker): mocker.patch.object(Output, 'from_json') session_id = 5 statement_json = {'id': 10, 'state': 'running', 'output': 'dummy output'} expected = Statement(session_id, statement_id=10, state=StatementState.RUNNING, output=Output.from_json.return_value) assert Statement.from_json(session_id, statement_json) == expected Output.from_json.assert_called_once_with('dummy output')
def test_statement_from_json_with_output(mocker): mocker.patch.object(Output, "from_json") session_id = 5 statement_json = {"id": 10, "state": "running", "output": "dummy output"} expected = Statement( session_id, statement_id=10, state=StatementState.RUNNING, output=Output.from_json.return_value, ) assert Statement.from_json(session_id, statement_json) == expected Output.from_json.assert_called_once_with("dummy output")
def test_statement_from_json_no_output(): session_id = 5 statement_json = { "id": 10, "state": "running", "code": "dummy code", "output": None, "progress": 0.0, } expected = Statement( session_id, statement_id=10, state=StatementState.RUNNING, code="dummy code", output=None, progress=0.0, ) assert Statement.from_json(session_id, statement_json) == expected
def test_statement_from_json_with_progress(mocker): mocker.patch.object(Output, "from_json") session_id = 5 statement_json = { "id": 10, "state": "running", "output": "dummy output", "progress": 0.5, } expected = Statement( session_id, statement_id=10, state=StatementState.RUNNING, output=Output.from_json.return_value, progress=0.5, ) assert Statement.from_json(session_id, statement_json) == expected