From ed07fc250cb6e72e79b69442ce98ce846bd016d8 Mon Sep 17 00:00:00 2001 From: hdoupe Date: Wed, 8 Jan 2020 12:01:24 -0500 Subject: [PATCH] Fix merge conflicts --- cs_storage/tests/test_cs_storage.py | 64 ++++++++++++----------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/cs_storage/tests/test_cs_storage.py b/cs_storage/tests/test_cs_storage.py index c311c9f..bb1f5db 100644 --- a/cs_storage/tests/test_cs_storage.py +++ b/cs_storage/tests/test_cs_storage.py @@ -15,13 +15,14 @@ def png(): import matplotlib.pyplot as plt import numpy as np + x = np.linspace(0, 2, 100) plt.figure() - plt.plot(x, x, label='linear') - plt.plot(x, x**2, label='quadratic') - plt.plot(x, x**3, label='cubic') - plt.xlabel('x label') - plt.ylabel('y label') + plt.plot(x, x, label="linear") + plt.plot(x, x ** 2, label="quadratic") + plt.plot(x, x ** 3, label="cubic") + plt.xlabel("x label") + plt.ylabel("y label") plt.title("Simple Plot") plt.legend() initial_buff = io.BytesIO() @@ -34,13 +35,14 @@ def png(): def jpg(): import matplotlib.pyplot as plt import numpy as np + x = np.linspace(0, 2, 100) plt.figure() - plt.plot(x, x, label='linear') - plt.plot(x, x**2, label='quadratic') - plt.plot(x, x**3, label='cubic') - plt.xlabel('x label') - plt.ylabel('y label') + plt.plot(x, x, label="linear") + plt.plot(x, x ** 2, label="quadratic") + plt.plot(x, x ** 3, label="cubic") + plt.xlabel("x label") + plt.ylabel("y label") plt.title("Simple Plot") plt.legend() initial_buff = io.BytesIO() @@ -115,32 +117,11 @@ def test_cs_storage(png, jpg): "title": "bokeh plot", "data": {"html": "
", "javascript": "console.log('hello world')"}, }, - { - "media_type": "table", - "title": "table stuff", - "data": "", - }, - { - "media_type": "PNG", - "title": "PNG data", - "data": png, - }, - { - "media_type": "JPEG", - "title": "JPEG data", - "data": jpg, - }, - { - "media_type": "MP3", - "title": "MP3 data", - "data": b"MP3 bytes", - }, - - { - "media_type": "MP4", - "title": "MP4 data", - "data": b"MP4 bytes", - }, + {"media_type": "table", "title": "table stuff", "data": "
"}, + {"media_type": "PNG", "title": "PNG data", "data": png}, + {"media_type": "JPEG", "title": "JPEG data", "data": jpg}, + {"media_type": "MP3", "title": "MP3 data", "data": b"MP3 bytes"}, + {"media_type": "MP4", "title": "MP4 data", "data": b"MP4 bytes"}, ], "downloadable": [ {"media_type": "CSV", "title": "CSV file", "data": "comma,sep,values\n"}, @@ -160,7 +141,7 @@ def test_cs_storage(png, jpg): } task_id = "1868c4a7-b03c-4fe4-ab45-0aa95c0bfa53" rem_res = cs_storage.write(task_id, exp_loc_res) - loc_res = cs_storage.read(rem_res) + loc_res = cs_storage.read(rem_res, json_serializable=False) for output_type in ["renderable", "downloadable"]: loc_res_without_id = [ {k: v for k, v in output.items() if k != "id"} @@ -172,7 +153,11 @@ def test_cs_storage(png, jpg): ] assert exp_res_without_id == loc_res_without_id - loc_res1 = cs_storage.read({"renderable": rem_res["renderable"]}) + assert json.dumps(cs_storage.read(rem_res, json_serializable=True)) + + loc_res1 = cs_storage.read( + {"renderable": rem_res["renderable"]}, json_serializable=False + ) loc_res_without_id = [ {k: v for k, v in output.items() if k != "id"} for output in loc_res1["renderable"] @@ -183,6 +168,9 @@ def test_cs_storage(png, jpg): ] assert exp_res_without_id == loc_res_without_id + assert json.dumps( + cs_storage.read({"renderable": rem_res["renderable"]}, json_serializable=True) + ) def test_add_screenshot_links():