def test_output_textdata_from_json(): output_json = {'status': 'ok', 'data': {'text/plain': 'some output'}} expected = Output(OutputStatus.OK, text='some output', json=None, ename=None, evalue=None, traceback=None) assert Output.from_json(output_json) == expected
def test_output_raise_for_status(): ok_output = Output(OutputStatus.OK, None, None, None, None, None) ok_output.raise_for_status() error_output = Output(OutputStatus.ERROR, None, None, None, None, None) with pytest.raises(SparkRuntimeError): error_output.raise_for_status()
def test_output_textdata_from_json(): output_json = {"status": "ok", "data": {"text/plain": "some output"}} expected = Output( OutputStatus.OK, text="some output", json=None, ename=None, evalue=None, traceback=None, ) assert Output.from_json(output_json) == expected
def test_output_jsondata_from_json(): output_json = { "status": "ok", "data": {"application/json": {"some": "data"}}, } expected = Output( OutputStatus.OK, text=None, json={"some": "data"}, ename=None, evalue=None, traceback=None, ) assert Output.from_json(output_json) == expected
def test_output_error_from_json(): output_json = { 'status': 'error', 'ename': 'SomeException', 'evalue': 'some error value', 'traceback': ['traceback line 1', 'traceback line 2'] } expected = Output(OutputStatus.ERROR, text=None, json=None, ename='SomeException', evalue='some error value', traceback=['traceback line 1', 'traceback line 2']) assert Output.from_json(output_json) == expected
def test_output_error_from_json(): output_json = { "status": "error", "ename": "SomeException", "evalue": "some error value", "traceback": ["traceback line 1", "traceback line 2"], } expected = Output( OutputStatus.ERROR, text=None, json=None, ename="SomeException", evalue="some error value", traceback=["traceback line 1", "traceback line 2"], ) assert Output.from_json(output_json) == expected
def test_output_jsondata_from_json(): output_json = { 'status': 'ok', 'data': { 'application/json': { 'some': 'data' } } } expected = Output(OutputStatus.OK, text=None, json={'some': 'data'}, ename=None, evalue=None, traceback=None) assert Output.from_json(output_json) == expected