#22 blackened code

This commit is contained in:
Alok Saldanha
2020-08-10 17:56:32 -04:00
parent 63cdfe1953
commit bfa80f7ef8
15 changed files with 295 additions and 151 deletions
+32 -29
View File
@@ -2,45 +2,48 @@ import unittest
from unittest.mock import MagicMock, patch
from cellxgene_gateway.filecrawl import render_entry
class TestRenderEntry(unittest.TestCase):
def test_GIVEN_path_both_slash_THEN_view_has_single_slash(self):
entry = {
"path": "/somepath/",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
"path": "/somepath/",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
rendered = render_entry(entry)
self.assertIn('view/somepath', rendered)
self.assertIn("view/somepath", rendered)
def test_GIVEN_path_starts_slash_THEN_view_has_single_slash(self):
entry = {
"path": "/somepath",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
"path": "/somepath",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
rendered = render_entry(entry)
self.assertIn('view/somepath', rendered)
self.assertIn("view/somepath", rendered)
def test_GIVEN_path_ends_slash_THEN_view_has_single_slash(self):
entry = {
"path": "somepath/",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
"path": "somepath/",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
rendered = render_entry(entry)
self.assertIn('view/somepath', rendered)
self.assertIn("view/somepath", rendered)
def test_GIVEN_path_no_slash_THEN_view_has_single_slash(self):
entry = {
"path": "somepath",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
"path": "somepath",
"name": "entry",
"type": "file",
"annotations": [],
"children": [],
}
rendered = render_entry(entry)
self.assertIn('view/somepath', rendered)
self.assertIn("view/somepath", rendered)
+10 -8
View File
@@ -2,22 +2,24 @@ import unittest
from unittest.mock import MagicMock, patch
from cellxgene_gateway.extra_scripts import get_extra_scripts
class TestExtraScripts(unittest.TestCase):
@patch('cellxgene_gateway.env.extra_scripts', new='["abc","def"]')
@patch("cellxgene_gateway.env.extra_scripts", new='["abc","def"]')
def test_GIVEN_two_scripts_THEN_returns_two_strings(self):
self.assertEqual(get_extra_scripts(), ['abc', 'def'])
self.assertEqual(get_extra_scripts(), ["abc", "def"])
@patch('cellxgene_gateway.env.extra_scripts', new='["abc", "def"]')
@patch("cellxgene_gateway.env.extra_scripts", new='["abc", "def"]')
def test_GIVEN_two_scripts_space_THEN_returns_two_strings(self):
self.assertEqual(get_extra_scripts(), ['abc', 'def'])
self.assertEqual(get_extra_scripts(), ["abc", "def"])
@patch('cellxgene_gateway.env.extra_scripts', new=None)
@patch("cellxgene_gateway.env.extra_scripts", new=None)
def test_GIVEN_none_THEN_returns_empty_array(self):
self.assertEqual(get_extra_scripts(), [])
@patch('cellxgene_gateway.env.extra_scripts', new='[]')
@patch("cellxgene_gateway.env.extra_scripts", new="[]")
def test_GIVEN_empty_string_THEN_returns_empty_array(self):
self.assertEqual(get_extra_scripts(), [])
if __name__ == '__main__':
unittest.main()
if __name__ == "__main__":
unittest.main()
+8 -6
View File
@@ -3,11 +3,12 @@ from unittest.mock import MagicMock, patch
from cellxgene_gateway.cache_entry import CacheEntry
from cellxgene_gateway.backend_cache import BackendCache
class TestPruneProcessCache(unittest.TestCase):
@patch('cellxgene_gateway.util.current_time_stamp', new=lambda:0)
@patch('cellxgene_gateway.env.ttl', new='10')
@patch('cellxgene_gateway.cache_entry.CacheEntry')
@patch('cellxgene_gateway.cache_entry.CacheEntry')
@patch("cellxgene_gateway.util.current_time_stamp", new=lambda: 0)
@patch("cellxgene_gateway.env.ttl", new="10")
@patch("cellxgene_gateway.cache_entry.CacheEntry")
@patch("cellxgene_gateway.cache_entry.CacheEntry")
def test_GIVEN_one_old_one_new_THEN_prune_old(self, old, new):
from cellxgene_gateway.prune_process_cache import PruneProcessCache
@@ -22,5 +23,6 @@ class TestPruneProcessCache(unittest.TestCase):
self.assertEqual(len(cache.entry_list), 1)
self.assertEqual(cache.entry_list[0], new)
if __name__ == '__main__':
unittest.main()
if __name__ == "__main__":
unittest.main()