def test_Builder_download(): # download b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366') assert b.loaded_map_json is not None assert b.loaded_model_json is not None b._get_html(js_source='web') # b.display_in_notebook(height=200) # data b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366', reaction_data=[{ 'GAPD': 123 }, { 'GAPD': 123 }]) b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366', metabolite_data=[{ 'nadh_c': 123 }, { 'nadh_c': 123 }]) b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366', gene_data=[{ 'gapA': 123 }, { 'adhE': 123 }]) assert type(b.the_id) is unicode_type assert len(b.the_id) == 10
def test__get_html(): b = Builder(map_json='"useless_map"', model_json='"useless_model"', embedded_css='') def look_for_string(st, substring): """Look for the string in the substring. This solves a bug in py.test for these cases""" try: found = st.find(substring) assert found > -1 except AssertionError: raise AssertionError('Could not find\n\n%s\n\nin\n\n%s' % (substring, st)) # no static parse, local html = b._get_html(js_source='local') look_for_string(html, 'map_data: JSON.parse(\'"useless_map"\'),') look_for_string(html, 'model_data: JSON.parse(\'"useless_model"\'),') look_for_string(html, 'escher.Builder(t_map_data, t_model_data, data.builder_embed_css,') # static parse, not dev static_index = '{"my": ["useless", "index"]}' html = b._get_html(static_site_index_json=static_index, protocol='https') look_for_string(html, 'map_data: JSON.parse(\'"useless_map"\'),') look_for_string(html, 'model_data: JSON.parse(\'"useless_model"\'),') look_for_string(html, 'map_download_url: JSON.parse(\'"https://escher.github.io/%s/%s/maps/"\'),' % (__schema_version__, __map_model_version__)) look_for_string(html, 'model_download_url: JSON.parse(\'"https://escher.github.io/%s/%s/models/"\'),' % (__schema_version__, __map_model_version__)) look_for_string(html, static_index) look_for_string(html, 'escher.Builder(t_map_data, t_model_data, data.builder_embed_css,')
def test__get_html(): b = Builder(map_json='"useless_map"', model_json='"useless_model"', embedded_css="") def look_for_string(st, substring): """Look for the string in the substring. This solves a bug in py.test for these cases""" try: found = st.find(substring) assert found > -1 except AssertionError: raise AssertionError("Could not find\n\n%s\n\nin\n\n%s" % (substring, st)) # no static parse, local html = b._get_html(js_source="local") look_for_string(html, "map_data: JSON.parse('\"useless_map\"'),") look_for_string(html, "model_data: JSON.parse('\"useless_model\"'),") look_for_string(html, "escher.Builder(t_map_data, t_model_data, data.builder_embed_css,") # static parse, not dev static_index = '{"my": ["useless", "index"]}' html = b._get_html(static_site_index_json=static_index, protocol="https") look_for_string(html, "map_data: JSON.parse('\"useless_map\"'),") look_for_string(html, "model_data: JSON.parse('\"useless_model\"'),") look_for_string( html, "map_download_url: JSON.parse('\"https://escher.github.io/%s/%s/maps/\"')," % (__schema_version__, __map_model_version__), ) look_for_string( html, "model_download_url: JSON.parse('\"https://escher.github.io/%s/%s/models/\"')," % (__schema_version__, __map_model_version__), ) look_for_string(html, static_index) look_for_string(html, "escher.Builder(t_map_data, t_model_data, data.builder_embed_css,")
def test__get_html(): b = Builder(map_json='"useless_map"', model_json='"useless_model"', embedded_css='') def look_for_string(st, substring): """Look for the string in the substring. This solves a bug in py.test for these cases""" try: found = st.find(substring) assert found > -1 except AssertionError: raise AssertionError('Could not find\n\n%s\n\nin\n\n%s' % (substring, st)) # no static parse, local html = b._get_html(js_source='local') look_for_string( html, 'map_data: JSON.parse(b64DecodeUnicode(\'InVzZWxlc3NfbWFwIg==\')),') look_for_string( html, 'model_data: JSON.parse(b64DecodeUnicode(\'InVzZWxlc3NfbW9kZWwi\')),') look_for_string( html, 'escher.Builder(t_map_data, t_model_data, data.builder_embed_css,') # static parse, not dev static_index = '{"my": ["useless", "index"]}' html = b._get_html(static_site_index_json=static_index, protocol='https') look_for_string( html, 'map_data: JSON.parse(b64DecodeUnicode(\'InVzZWxlc3NfbWFwIg==\')),') look_for_string( html, 'model_data: JSON.parse(b64DecodeUnicode(\'InVzZWxlc3NfbW9kZWwi\')),') map_download_url = base64.b64encode( ("https://escher.github.io/%s/%s/maps/" % (__schema_version__, __map_model_version__)).encode('utf-8')).decode('utf-8') look_for_string( html, 'map_download_url: b64DecodeUnicode(\'%s\'),' % map_download_url) model_download_url = base64.b64encode( ("https://escher.github.io/%s/%s/models/" % (__schema_version__, __map_model_version__)).encode('utf-8')).decode('utf-8') look_for_string( html, 'model_download_url: b64DecodeUnicode(\'%s\'),' % model_download_url) look_for_string(html, 'eyJteSI6IFsidXNlbGVzcyIsICJpbmRleCJdfQ==') # static_index look_for_string( html, 'escher.Builder(t_map_data, t_model_data, data.builder_embed_css,')
def test_Builder_download(): # download b = Builder(map_name="iJO1366.Central metabolism", model_name="iJO1366") assert b.loaded_map_json is not None assert b.loaded_model_json is not None b._get_html(js_source="web") # b.display_in_notebook(height=200) # data b = Builder( map_name="iJO1366.Central metabolism", model_name="iJO1366", reaction_data=[{"GAPD": 123}, {"GAPD": 123}] ) b = Builder( map_name="iJO1366.Central metabolism", model_name="iJO1366", metabolite_data=[{"nadh_c": 123}, {"nadh_c": 123}] ) b = Builder(map_name="iJO1366.Central metabolism", model_name="iJO1366", gene_data=[{"gapA": 123}, {"adhE": 123}]) assert type(b.the_id) is unicode_type assert len(b.the_id) == 10
def test_Builder_download(): # download b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366') assert b.loaded_map_json is not None assert b.loaded_model_json is not None b._get_html(js_source='web') b.display_in_notebook(height=200) # data b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366', reaction_data=[{'GAPD': 123}, {'GAPD': 123}]) b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366', metabolite_data=[{'nadh_c': 123}, {'nadh_c': 123}]) b = Builder(map_name='iJO1366.Central metabolism', model_name='iJO1366', gene_data=[{'gapA': 123}, {'adhE': 123}]) assert type(b.the_id) is unicode_type assert len(b.the_id) == 10
def test_Builder(tmpdir): # ok with embedded_css arg b = Builder(map_json='{"r": "val"}', model_json='{"r": "val"}', embedded_css='') # b.display_in_notebook(js_source='local') b.save_html(join(str(tmpdir), 'Builder.html'), js_source='local') # test options with raises(Exception): b._get_html(js_source='devv') with raises(Exception): b._get_html(menu='') with raises(Exception): b._get_html(scroll_behavior='asdf') b._get_html(js_source='local') b._get_html(menu='all') b._get_html(scroll_behavior='zoom')
def test_Builder_options(): b = Builder(embedded_css='') b.set_metabolite_no_data_color('white') assert b.metabolite_no_data_color=='white' html = b._get_html(js_source='local') assert 'metabolite_no_data_color: "white"' in html
def test_Builder(tmpdir): b = Builder(map_json='{"r": "val"}', model_json='{"r": "val"}') # Cannot load dev/local version without an explicit css string property. # TODO include a test where these do not raise. with raises(Exception): b.display_in_notebook(js_source='dev') with raises(Exception): b.display_in_notebook(js_source='local') # ok with embedded_css arg b = Builder(map_json='{"r": "val"}', model_json='{"r": "val"}', embedded_css='') b.display_in_notebook(js_source='dev') b.save_html(join(str(tmpdir), 'Builder.html'), js_source='dev') # test options with raises(Exception): b._get_html(js_source='devv') with raises(Exception): b._get_html(menu='') with raises(Exception): b._get_html(scroll_behavior='asdf') b._get_html(js_source='local') b._get_html(menu='all') b._get_html(scroll_behavior='zoom')
def test_Builder_options(): b = Builder(embedded_css="") b.set_metabolite_no_data_color("white") assert b.metabolite_no_data_color == "white" html = b._get_html(js_source="local") assert '"metabolite_no_data_color": "white"' in html
def test_Builder(tmpdir): # ok with embedded_css arg b = Builder(map_json='{"r": "val"}', model_json='{"r": "val"}', embedded_css="") # b.display_in_notebook(js_source='local') b.save_html(join(str(tmpdir), "Builder.html"), js_source="local") # test options with raises(Exception): b._get_html(js_source="devv") with raises(Exception): b._get_html(menu="") with raises(Exception): b._get_html(scroll_behavior="asdf") b._get_html(js_source="local") b._get_html(menu="all") b._get_html(scroll_behavior="zoom")
def test_Builder(tmpdir): b = Builder(map_json='{"r": "val"}', model_json='{"r": "val"}') # Cannot load dev/local version without an explicit css string property. # TODO include a test where these do not raise. with raises(Exception): b.display_in_notebook(js_source='dev') with raises(Exception): b.display_in_notebook(js_source='local') b.display_in_notebook(js_source='web') b.display_in_notebook(height=200) # b.display_in_browser() b.save_html(join(str(tmpdir), 'Builder.html')) # test options with raises(Exception): b._get_html(js_source='devv') with raises(Exception): b._get_html(menu='') with raises(Exception): b._get_html(scroll_behavior='asdf') b._get_html(js_source='web') b._get_html(menu='all') b._get_html(scroll_behavior='zoom') # download b = Builder(map_name='iJO1366_central_metabolism', model_name='iJO1366') assert b.loaded_map_json is not None assert b.loaded_model_json is not None b.display_in_notebook(height=200) # data b = Builder(map_name='iJO1366_central_metabolism', model_name='iJO1366', reaction_data=[{'GAPD': 123}, {'GAPD': 123}]) b = Builder(map_name='iJO1366_central_metabolism', model_name='iJO1366', metabolite_data=[{'nadh_c': 123}, {'nadh_c': 123}]) assert type(b.the_id) is unicode assert len(b.the_id) == 10
def test_Builder(tmpdir): # ok with embedded_css arg b = Builder(map_json='{"r": "val"}', model_json='{"r": "val"}', embedded_css='') b.display_in_notebook(js_source='local') b.save_html(join(str(tmpdir), 'Builder.html'), js_source='local') # test options with raises(Exception): b._get_html(js_source='devv') with raises(Exception): b._get_html(menu='') with raises(Exception): b._get_html(scroll_behavior='asdf') b._get_html(js_source='local') b._get_html(menu='all') b._get_html(scroll_behavior='zoom')