mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-10 23:00:56 +08:00
#81 added unit test for gene sets
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from cellxgene_gateway.backend_cache import BackendCache
|
|
||||||
from cellxgene_gateway.cache_entry import CacheEntry
|
from cellxgene_gateway.cache_entry import CacheEntry
|
||||||
from cellxgene_gateway.cache_key import CacheKey
|
from cellxgene_gateway.cache_key import CacheKey
|
||||||
from cellxgene_gateway.items.file.fileitem import FileItem
|
from cellxgene_gateway.items.file.fileitem import FileItem
|
||||||
@@ -40,3 +39,39 @@ class TestSubprocessBackend(unittest.TestCase):
|
|||||||
stdout=-1,
|
stdout=-1,
|
||||||
)
|
)
|
||||||
self.assertEqual("An unexpected error", context.exception.stderr)
|
self.assertEqual("An unexpected error", context.exception.stderr)
|
||||||
|
|
||||||
|
@patch("subprocess.Popen")
|
||||||
|
def test_launch_GIVEN_annotations_enabled_THEN_set_flags(self, popen):
|
||||||
|
subprocess = MagicMock()
|
||||||
|
subprocess.stdout.readline().decode.return_value = (
|
||||||
|
"[cellxgene] Type CTRL-C at any time to exit.\n"
|
||||||
|
)
|
||||||
|
subprocess.stderr.read().decode.return_value = ""
|
||||||
|
popen.return_value = subprocess
|
||||||
|
|
||||||
|
key = CacheKey(
|
||||||
|
FileItem("/czi/", name="pbmc3k.h5ad", type=ItemType.h5ad),
|
||||||
|
FileItemSource("/tmp", "local"),
|
||||||
|
FileItem(
|
||||||
|
"/czi/pbmc3k_annotations/", name="foo.csv", type=ItemType.annotation
|
||||||
|
),
|
||||||
|
)
|
||||||
|
entry = CacheEntry.for_key(key, 8000)
|
||||||
|
import cellxgene_gateway.subprocess_backend
|
||||||
|
|
||||||
|
cellxgene_gateway.subprocess_backend.enable_annotations = True
|
||||||
|
try:
|
||||||
|
backend = cellxgene_gateway.subprocess_backend.SubprocessBackend()
|
||||||
|
cellxgene_loc = "/some/cellxgene"
|
||||||
|
|
||||||
|
backend.launch(cellxgene_loc, [], entry)
|
||||||
|
finally:
|
||||||
|
cellxgene_gateway.subprocess_backend.enable_annotations = False
|
||||||
|
popen.assert_called_once_with(
|
||||||
|
[
|
||||||
|
"yes | /some/cellxgene launch /tmp/czi/pbmc3k.h5ad --port 8000 --host 127.0.0.1 --annotations-file /tmp/czi/pbmc3k_annotations/foo.csv --gene-sets-file /tmp/czi/pbmc3k_annotations/foo_gene_sets.csv"
|
||||||
|
],
|
||||||
|
shell=True,
|
||||||
|
stderr=-1,
|
||||||
|
stdout=-1,
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user