Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Strand Lab
Strand Lab Cellxgene Gateway
Commits
d2d22cec
Commit
d2d22cec
authored
Apr 02, 2021
by
Alok Saldanha
Browse files
updated tests, formatting
parent
5c488d8d
Changes
4
Hide whitespace changes
Inline
Side-by-side
.github/workflows/pr-checks.yaml
View file @
d2d22cec
...
...
@@ -22,7 +22,7 @@ jobs:
pip install black
-
name
:
Run black
run
:
|
black
-l 79
. --check
black . --check
# This job is copied over from `deploy.yaml`
run-tests
:
runs-on
:
ubuntu-18.04
...
...
cellxgene_gateway/items/s3/s3item_source.py
View file @
d2d22cec
...
...
@@ -29,8 +29,10 @@ class S3ItemSource(ItemSource):
):
self
.
_name
=
name
self
.
s3
=
s3fs
.
S3FileSystem
()
if
bucket
.
startswith
(
's3://'
):
raise
Exception
(
f
"Bucket name should not include s3:// prefix, got
{
bucket
}
"
)
if
bucket
.
startswith
(
"s3://"
):
raise
Exception
(
f
"Bucket name should not include s3:// prefix, got
{
bucket
}
"
)
self
.
bucket
=
bucket
self
.
h5ad_suffix
=
h5ad_suffix
self
.
annotation_dir_suffix
=
annotation_dir_suffix
...
...
@@ -69,7 +71,7 @@ class S3ItemSource(ItemSource):
raise
Exception
(
f
"S3 url '
{
url
}
' does not exist."
)
s3key_map
=
dict
(
(
filepath
[
len
(
self
.
bucket
)
:].
lstrip
(
'/'
),
"s3://"
+
filepath
)
(
filepath
[
len
(
self
.
bucket
)
:].
lstrip
(
"/"
),
"s3://"
+
filepath
)
for
filepath
in
sorted
(
self
.
s3
.
ls
(
url
))
)
...
...
tests/items/file/test_fileitem_source.py
View file @
d2d22cec
...
...
@@ -5,7 +5,9 @@ from cellxgene_gateway.items.file.fileitem_source import FileItemSource
class
TestFileItemSource
(
unittest
.
TestCase
):
def
test_make_fileitem_from_path_GIVEN_annotation_file_THEN_name_lacks_csv
(
self
):
def
test_make_fileitem_from_path_GIVEN_annotation_file_THEN_name_lacks_csv
(
self
,
):
source
=
FileItemSource
(
tempfile
.
gettempdir
(),
"local"
)
item
=
source
.
make_fileitem_from_path
(
"customanno.csv"
,
"someh5ad_annotations"
,
True
...
...
tests/test_cache_entry.py
View file @
d2d22cec
...
...
@@ -2,6 +2,7 @@ import unittest
from
flask
import
Flask
from
cellxgene_gateway
import
flask_util
from
cellxgene_gateway.cache_entry
import
CacheEntry
,
CacheEntryStatus
from
cellxgene_gateway.cache_key
import
CacheKey
from
cellxgene_gateway.gateway
import
app
...
...
@@ -27,13 +28,31 @@ class TestRenderEntry(unittest.TestCase):
self
.
assertEqual
(
entry
.
status
,
CacheEntryStatus
.
loading
)
def
test_GIVEN_absolute_static_url_THEN_include_path
(
self
):
flask_util
.
include_source_in_url
=
False
actual
=
CacheEntry
.
for_key
(
key
,
8000
).
rewrite_text_content
(
"src:url(/static/assets/"
)
expected
=
"src:url(/
source/local/
view/czi/pbmc3k.h5ad/static/assets/"
expected
=
"src:url(/view/czi/pbmc3k.h5ad/static/assets/"
self
.
assertEqual
(
actual
,
expected
)
def
test_GIVEN_absolute_src_THEN_include_path
(
self
):
flask_util
.
include_source_in_url
=
False
actual
=
CacheEntry
.
for_key
(
key
,
8000
).
rewrite_text_content
(
'<link rel="shortcut icon" href="/static/assets/favicon.ico">'
)
expected
=
'<link rel="shortcut icon" href="/view/czi/pbmc3k.h5ad/static/assets/favicon.ico">'
self
.
assertEqual
(
actual
,
expected
)
def
test_GIVEN_absolute_static_url_include_source_THEN_include_path
(
self
):
flask_util
.
include_source_in_url
=
True
actual
=
CacheEntry
.
for_key
(
key
,
8000
).
rewrite_text_content
(
"src:url(/static/assets/"
)
expected
=
"src:url(/source/local/view/czi/pbmc3k.h5ad/static/assets/"
self
.
assertEqual
(
actual
,
expected
)
def
test_GIVEN_absolute_src_include_source_THEN_include_path
(
self
):
flask_util
.
include_source_in_url
=
True
actual
=
CacheEntry
.
for_key
(
key
,
8000
).
rewrite_text_content
(
'<link rel="shortcut icon" href="/static/assets/favicon.ico">'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment