added unit test

This commit is contained in:
Alok Saldanha
2019-09-16 10:58:02 -04:00
parent 15998beb68
commit 1e1de19878
5 changed files with 51 additions and 18 deletions
+16 -15
View File
@@ -24,21 +24,22 @@ env_vars = {
"GATEWAY_IP": ip,
}
if not all(env_vars.values()):
raise ValueError(
f"""
Please ensure that environment variables are set correctly.
The ones with None below are missing and need to be set.
def validate():
if not all(env_vars.values()):
raise ValueError(
f"""
Please ensure that environment variables are set correctly.
The ones with None below are missing and need to be set.
{env_vars}
{env_vars}
Set them at the terminal before running the gateway.
An example is:
Set them at the terminal before running the gateway.
An example is:
export CELLXGENE_LOCATION=~/anaconda/envs/cellxgene-dev/bin/cellxgene
export CELLXGENE_DATA=../cellxgene_data
export GATEWAY_HOST=localhost:5005
export GATEWAY_PROTOCOL=http
export GATEWAY_IP=127.0.0.1
"""
)
export CELLXGENE_LOCATION=~/anaconda/envs/cellxgene-dev/bin/cellxgene
export CELLXGENE_DATA=../cellxgene_data
export GATEWAY_HOST=localhost:5005
export GATEWAY_PROTOCOL=http
export GATEWAY_IP=127.0.0.1
"""
)
+2 -1
View File
@@ -8,10 +8,11 @@
# the specific language governing permissions and limitations under the License.
from cellxgene_gateway import env
from json import loads
def get_extra_scripts():
# can be array of script tags to inject on every page, e.g. for google analytics could be
# ['https://www.googletagmanager.com/gtag/js?id=UA-123456-2',
# f"{env.gateway_protocol}://{env.gateway_host}/static/js/google_ua.js"]
# where google_ua.js is a script you add to the static/js folder prior to deployment.
return [] if env.extra_scripts is None else [p.strip() for p in env.extra_scripts.split(",") if len(p.strip()) > 0]
return [] if env.extra_scripts is None else loads(env.extra_scripts)
+1
View File
@@ -184,6 +184,7 @@ def do_GET(path):
def main():
env.validate()
background_thread = Thread(target=PruneProcessCache(cache))
background_thread.start()