Skip to content

Commit

Permalink
Merge pull request #147 from 0Hughman0/cas-project
Browse files Browse the repository at this point in the history
Making cas_project expected name of module that defines project.
  • Loading branch information
0Hughman0 authored Aug 21, 2024
2 parents 963033d + 18be278 commit 5e9889c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cassini/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def find_project(import_string=None):
path/to/module:project_obj
By default, `project_obj` is assumed to be called `project`. This will be imported from `module`.
By default, `project_obj` is assumed to be called `project`. This will be imported from `module`, which by default is
assumed to be `cas_project`.
Note that for cassini to run with a regular jupyterlab instance, `ContentsManager.allow_hidden = True` must be set, either
via a config, or passed as a command line argument e.g. `--ContentsManager.allow_hidden=True`
Expand Down Expand Up @@ -232,7 +233,7 @@ def find_project(import_string=None):
obj = "project"
elif path.is_dir():
directory = path.as_posix()
module = "project"
module = "cas_project"
obj = "project"
else:
raise RuntimeError(f"Cannot parse CASSINI_PROJECT {CASSINI_PROJECT}")

Check warning on line 239 in cassini/utils.py

View check run for this annotation

Codecov / codecov/patch

cassini/utils.py#L239

Added line #L239 was not covered by tests
Expand Down
12 changes: 6 additions & 6 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def wrapped():
Project._instance = None
env.project = None

if 'project' in sys.modules:
del sys.modules['project']
if 'cas_project' in sys.modules:
del sys.modules['cas_project']
if 'my_project' in sys.modules:
del sys.modules['my_project']

Expand All @@ -33,7 +33,7 @@ def wrapped():


def test_find_not_set(tmp_path, refresh_project):
project = shutil.copy('tests/project_cases/basic.py', tmp_path / 'project.py')
project = shutil.copy('tests/project_cases/basic.py', tmp_path / 'cas_project.py')

refresh_project()

Expand All @@ -49,7 +49,7 @@ def test_find_not_set(tmp_path, refresh_project):
itertools.product(
['basic.py', 'not_project.py'],
['', 'subdir'],
['project.py', 'my_project.py'],
['cas_project.py', 'my_project.py'],
['{module}', '{module_file}', '{directory}'],
['', ':{project_obj}'],
[False, True]
Expand All @@ -63,8 +63,8 @@ def cas_project(request, tmp_path, refresh_project):
if obj_format == ':{project_obj}' and module_format == '{directory}':
return pytest.skip("Valid CASSINI_PATH cannot be constructed from directory and object specifier")

if module_format == '{directory}' and project_out != 'project.py':
return pytest.skip("Valid CASSINI_PATH cannot be constructed from directory if project not called project.py")
if module_format == '{directory}' and project_out != 'cas_project.py':
return pytest.skip("Valid CASSINI_PATH cannot be constructed from directory if project not called cas_project.py")

if module_format == '{module}' and subdir:
return pytest.skip("Valid CASSINI_PATH cannot be constructed from just module if it's inside a subdir")
Expand Down

0 comments on commit 5e9889c

Please sign in to comment.