Skip to content

Commit

Permalink
fix: two issues related to custom site config directory
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Dec 9, 2024
1 parent 160906b commit 4bf82a3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.11.8
- fix: get_dcor_site_config_dir did not always return a pathlib.Path (#20)
- fix: --dcor-site-config-dir CLI argument did not accept directory (#20)
0.11.7
- fix: don't try to edit client_max_body_size
0.11.6
Expand Down
3 changes: 2 additions & 1 deletion dcor_control/cli/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
@click.command()
@click.option('--assume-yes', is_flag=True)
@click.option("--dcor-site-config-dir",
type=click.Path(dir_okay=False,
type=click.Path(dir_okay=True,
file_okay=False,
resolve_path=True,
path_type=pathlib.Path),
help="Path to a custom site configuration. For the main "
Expand Down
1 change: 1 addition & 0 deletions dcor_control/inspect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
check_dcor_theme_i18n_hack,
check_dcor_theme_main_css,
check_ckan_uploader_patch_to_support_symlinks,
get_dcor_site_config_dir,
)
from .config_nginx import check_nginx
from .config_supervisord import (
Expand Down
4 changes: 2 additions & 2 deletions dcor_control/inspect/config_ckan.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def get_actual_ckan_option(key):
return opt


def get_dcor_site_config_dir(dcor_site_config_dir=None):
def get_dcor_site_config_dir(dcor_site_config_dir=None) -> pathlib.Path:
"""Return a local directory on disk containing the site's configuration
The configuration directory is searched for in the following order:
Expand Down Expand Up @@ -204,7 +204,7 @@ def get_dcor_site_config_dir(dcor_site_config_dir=None):
f"The site configuration directory '{dcor_site_config_dir}' is "
f"not applicable. Please check hostname and IP address.")

return dcor_site_config_dir
return pathlib.Path(dcor_site_config_dir)


def get_expected_site_options(dcor_site_config_dir):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_inspect_data_ckan.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import pathlib
from unittest import mock

Expand Down Expand Up @@ -102,3 +103,18 @@ def test_check_orphaned_s3_artifacts(enqueue_job_mock, create_with_upload,
inspect.check_orphaned_s3_artifacts(assume_yes=True,
older_than_days=0)
assert not s3.object_exists(bucket_name, object_name)


def test_get_dcor_site_config_dir():
cur_dir = os.environ.get("DCOR_SITE_CONFIG_DIR")
try:
os.environ["DCOR_SITE_CONFIG_DIR"] = "/tmp/test"
assert str(inspect.get_dcor_site_config_dir()) == "/tmp/test"
except BaseException:
raise
finally:
# cleanup
if cur_dir is not None:
os.environ["DCOR_SITE_CONFIG_DIR"] = cur_dir
else:
os.environ.pop("DCOR_SITE_CONFIG_DIR")

0 comments on commit 4bf82a3

Please sign in to comment.