def test_server_template_static_resources_with_prefix_relative_url(): template = BootstrapTemplate() port = 6003 serve({'template': template}, port=port, threaded=True, show=False, prefix='prefix') # Wait for server to start time.sleep(1) r = requests.get(f"http://localhost:{port}/prefix/template") content = r.content.decode('utf-8') assert 'href="static/extensions/panel/bundled/bootstraptemplate/bootstrap.css"' in content
def test_server_template_static_resources_with_prefix(): template = BootstrapTemplate() port = 6002 serve({'template': template}, port=port, threaded=True, show=False, prefix='prefix') # Wait for server to start time.sleep(1) r = requests.get(f"http://localhost:{port}/prefix/static/extensions/panel/bundled/bootstraptemplate/bootstrap.css") with open(DIST_DIR / 'bundled' / 'bootstraptemplate' / 'bootstrap.css', encoding='utf-8') as f: assert f.read() == r.content.decode('utf-8').replace('\r\n', '\n')
def test_server_template_static_resources(): template = BootstrapTemplate() server = serve({'template': template}, port=6001, threaded=True, show=False) # Wait for server to start time.sleep(1) try: r = requests.get("http://localhost:6001/static/extensions/panel/bundled/bootstraptemplate/bootstrap.css") with open(DIST_DIR / 'bundled' / 'bootstraptemplate' / 'bootstrap.css', encoding='utf-8') as f: assert f.read() == r.content.decode('utf-8').replace('\r\n', '\n') finally: server.stop()
def test_server_template_static_resources_with_subpath_and_prefix_relative_url(): template = BootstrapTemplate() server = serve({'/subpath/template': template}, port=6005, threaded=True, show=False, prefix='prefix') # Wait for server to start time.sleep(1) try: r = requests.get("http://localhost:6005/prefix/subpath/template") content = r.content.decode('utf-8') assert 'href="../static/extensions/panel/bundled/bootstraptemplate/bootstrap.css"' in content finally: server.stop()