Skip to content

Commit

Permalink
Update settings tests to include overrides.
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Jul 26, 2018
1 parent c229c58 commit 4d4a491
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
5 changes: 5 additions & 0 deletions jupyterlab_launcher/tests/app-settings/overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"@jupyterlab/apputils-extension:themes": {
"theme": "JupyterLab Dark"
}
}
20 changes: 17 additions & 3 deletions jupyterlab_launcher/tests/test_settings_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,35 @@ class SettingsAPITest(LabTestBase):
"""Test the settings web service API"""

def setUp(self):
# Copy the schema files.
src = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'schemas',
'@jupyterlab')
dst = os.path.join(self.lab_config.schemas_dir, '@jupyterlab')
if not os.path.exists(dst):
shutil.copytree(src, dst)
if os.path.exists(dst):
shutil.rmtree(dst)
shutil.copytree(src, dst)

# Copy the overrides file.
src = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'app-settings',
'overrides.json')
dst = os.path.join(self.lab_config.app_settings_dir, 'overrides.json')
if os.path.exists(dst):
os.remove(dst)
shutil.copyfile(src, dst)
self.settings_api = SettingsAPI(self.request)

def test_get(self):
id = '@jupyterlab/apputils-extension:themes'
data = self.settings_api.get(id).json()
schema = data['schema']

assert data['id'] == id
assert len(data['schema'])
# Check that overrides.json file is respected.
assert schema['properties']['theme']['default'] == 'JupyterLab Dark'
assert 'raw' in data

def test_get_bad(self):
Expand Down
5 changes: 3 additions & 2 deletions jupyterlab_launcher/tests/test_workspaces_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def setUp(self):
for item in os.listdir(data):
src = os.path.join(data, item)
dst = os.path.join(self.lab_config.workspaces_dir, item)
if not os.path.exists(dst):
shutil.copy(src, self.lab_config.workspaces_dir)
if os.path.exists(dst):
os.remove(dst)
shutil.copy(src, self.lab_config.workspaces_dir)
self.workspaces_api = WorkspacesAPI(self.request)

def test_delete(self):
Expand Down
2 changes: 2 additions & 0 deletions jupyterlab_launcher/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def tmp(*parts):
cls.config_dir = tmp('config')
cls.runtime_dir = tmp('runtime')
cls.lab_dir = tmp('lab')
cls.app_settings_dir = tmp('appsettings')
cls.lab_schemas = tmp('labschemas')
cls.lab_settings = tmp('labsettings')
cls.lab_workspaces = tmp('labworkspaces')
Expand All @@ -60,6 +61,7 @@ def tmp(*parts):
})
cls.env_patch.start()
cls.lab_config = LabConfig(
app_settings_dir=cls.app_settings_dir,
schemas_dir=cls.lab_schemas,
user_settings_dir=cls.lab_settings,
workspaces_dir=cls.lab_workspaces)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"data": {}, "metadata": {"id": "foo"}}
{"data": {}, "metadata": {"id": "foo"}}

0 comments on commit 4d4a491

Please sign in to comment.