/
test_all.py
49 lines (40 loc) · 1.61 KB
/
test_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
import importlib
import os.path
import sys
def test_config_paths():
assert os.path.exists('/etc/profile.d/init_conda.sh')
assert os.path.exists('/srv/conda/.condarc')
assert os.path.exists('/srv/start')
def test_environment_variables():
# These are required for jupyterhub and binderhub compatibility
assert os.environ['NB_USER'] == 'jovyan'
assert os.environ['NB_UID'] == '1000'
assert 'NB_PYTHON_PREFIX' in os.environ
def test_default_conda_environment():
assert sys.prefix == '/srv/conda/envs/notebook'
packages = [
# included in pangeo-notebook metapackage
# https://github.com/conda-forge/pangeo-notebook-feedstock/blob/master/recipe/meta.yaml
'dask', 'distributed', 'dask_gateway', 'dask_labextension', #dask_kubernetes (now using dask-gateway)
# jupyterhub and related utilities
'jupyterhub', 'jupyterlab', 'nbgitpuller'
]
@pytest.mark.parametrize('package_name', packages, ids=packages)
def test_import(package_name):
importlib.import_module(package_name)
def test_dask_config():
import dask
assert '/srv/conda/etc' in dask.config.paths
assert dask.config.config['labextension']['factory']['class'] == 'LocalCluster'
# Works locally but hanging on GitHub Actions, possibly due to:
# Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7ff7a2931950>
#@pytest.fixture(scope='module')
#def client():
# from dask.distributed import Client
# with Client(n_workers=4) as dask_client:
# yield dask_client
#
#def test_check_dask_version(client):
# print(client)
# versions = client.get_versions(check=True)