mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-16 05:17:55 +08:00
Compare commits
3 Commits
68_read_fr
...
73_reorder
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a00403c60e | ||
|
|
390fe24ea4 | ||
|
|
590565bea2 |
@@ -1,3 +1,10 @@
|
||||
# 0.3.10
|
||||
|
||||
* #65 Added GATEWAY_EXPIRE_SECONDS to set how long cellxgene servers can remain idle before being terminated.
|
||||
* Added GATEWAY_LOG_LEVEL to set the log level
|
||||
* #68 Close connections after reading response
|
||||
* #68 Background thread reads from output of cellxgene process until it exits
|
||||
|
||||
# 0.3.9
|
||||
|
||||
* Added S3_ENABLE_LISTINGS_CACHE variable (See README.md)
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
# the specific language governing permissions and limitations under the License.
|
||||
|
||||
__version__ = "0.3.9"
|
||||
__version__ = "0.3.10"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
# the specific language governing permissions and limitations under the License.
|
||||
|
||||
import os
|
||||
import html
|
||||
import urllib.parse
|
||||
|
||||
from cellxgene_gateway import env, flask_util
|
||||
@@ -19,19 +19,17 @@ def render_annotations(item, item_source):
|
||||
url = flask_util.view_url(
|
||||
item_source.get_annotations_subpath(item), item_source.name
|
||||
)
|
||||
new_annotation = f"<a class='new' href='{url}'>new</a>"
|
||||
new_annotation = [f"<a class='new' href='{url}'>new</a>"]
|
||||
|
||||
annotations = (
|
||||
", ".join(
|
||||
[
|
||||
f"<a href='{CacheKey(item, item_source, a).view_url}/'>{a.name}</a>"
|
||||
for a in item.annotations
|
||||
]
|
||||
)
|
||||
+ ", "
|
||||
[
|
||||
f"<a href='{CacheKey(item, item_source, a).view_url}/'>{html.escape(a.name)}</a>"
|
||||
for a in item.annotations
|
||||
]
|
||||
if item.annotations
|
||||
else ""
|
||||
else []
|
||||
)
|
||||
return " | annotations: " + annotations + new_annotation
|
||||
return "| annotations: " + ", ".join(new_annotation + annotations)
|
||||
|
||||
|
||||
def render_item(item, item_source):
|
||||
|
||||
@@ -13,26 +13,76 @@ from cellxgene_gateway.items.item import ItemTree, ItemType
|
||||
source = FileItemSource("/tmp")
|
||||
|
||||
|
||||
def make_entry(subpath="somepath", annotations=None):
|
||||
return FileItem(
|
||||
subpath=subpath,
|
||||
name="entry",
|
||||
ext=".h5ad",
|
||||
type=ItemType.h5ad,
|
||||
annotations=annotations,
|
||||
)
|
||||
|
||||
|
||||
class TestRenderEntry(unittest.TestCase):
|
||||
def test_GIVEN_path_both_slash_THEN_view_has_single_slash(self):
|
||||
entry = FileItem(subpath="/somepath/", name="entry", type=ItemType.h5ad)
|
||||
entry = make_entry(subpath="/somepath/")
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn("view/somepath/entry/'", rendered)
|
||||
self.assertIn("view/somepath/entry.h5ad/'", rendered)
|
||||
|
||||
def test_GIVEN_path_starts_slash_THEN_view_has_single_slash(self):
|
||||
entry = FileItem(subpath="/somepath", name="entry", type=ItemType.h5ad)
|
||||
entry = make_entry(subpath="/somepath")
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn("view/somepath/entry/'", rendered)
|
||||
self.assertIn("view/somepath/entry.h5ad/'", rendered)
|
||||
|
||||
def test_GIVEN_path_ends_slash_THEN_view_has_single_slash(self):
|
||||
entry = FileItem(subpath="somepath/", name="entry", type=ItemType.h5ad)
|
||||
entry = make_entry(subpath="somepath/")
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn("view/somepath/entry/'", rendered)
|
||||
self.assertIn("view/somepath/entry.h5ad/'", rendered)
|
||||
|
||||
def test_GIVEN_path_no_slash_THEN_view_has_single_slash(self):
|
||||
entry = FileItem(subpath="somepath", name="entry", type=ItemType.h5ad)
|
||||
entry = make_entry(subpath="somepath")
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn("view/somepath/entry/'", rendered)
|
||||
self.assertIn("view/somepath/entry.h5ad/'", rendered)
|
||||
|
||||
|
||||
class TestRenderAnnotation(unittest.TestCase):
|
||||
def test_GIVEN_no_annotation_THEN_new_alone(self):
|
||||
entry = make_entry(annotations=None)
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn(
|
||||
"> | annotations: <a class='new' href='/source/Files:/tmp/view/somepath/entry_annotations'>new</a></li>",
|
||||
rendered,
|
||||
)
|
||||
|
||||
def test_GIVEN_annotation_THEN_new_before(self):
|
||||
annotation = FileItem(
|
||||
subpath="somepath/entry_annotations",
|
||||
name="annot",
|
||||
ext=".csv",
|
||||
type=ItemType.annotation,
|
||||
)
|
||||
entry = make_entry(annotations=[annotation])
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn(
|
||||
"> | annotations: <a class='new' href='/source/Files:/tmp/view/somepath/entry_annotations'>new</a>,"
|
||||
" <a href='/source/Files:/tmp/view/somepath/entry_annotations/annot.csv/'>annot</a></li>",
|
||||
rendered,
|
||||
)
|
||||
|
||||
def test_GIVEN_annotation_THEN_escaped(self):
|
||||
annotation = FileItem(
|
||||
subpath="somepath/entry_annotations",
|
||||
name="hot&cold",
|
||||
ext=".csv",
|
||||
type=ItemType.annotation,
|
||||
)
|
||||
entry = make_entry(annotations=[annotation])
|
||||
rendered = render_item(entry, source)
|
||||
self.assertIn(
|
||||
"> | annotations: <a class='new' href='/source/Files:/tmp/view/somepath/entry_annotations'>new</a>,"
|
||||
" <a href='/source/Files:/tmp/view/somepath/entry_annotations/hot%26cold.csv/'>hot&cold</a></li>",
|
||||
rendered,
|
||||
)
|
||||
|
||||
|
||||
class TestRenderItemSource(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user