From 6b1622bcecce4d290b901abc522d257d22c4c04e Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 23 Jun 2020 22:43:51 -0700 Subject: [PATCH] cfg: Rename configuration file to freedombox.config Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- conftest.py | 2 +- plinth/__main__.py | 2 +- plinth/cfg.py | 2 +- .../freedombox.config} | 0 .../freedombox.config.with_missing_options} | 0 .../freedombox.config.with_missing_sections} | 0 plinth/tests/test_cfg.py | 22 +++++++++---------- 7 files changed, 14 insertions(+), 14 deletions(-) rename plinth/tests/data/{etc/plinth/plinth.config => configs/freedombox.config} (100%) rename plinth/tests/data/{plinth.config.with_missing_options => configs/freedombox.config.with_missing_options} (100%) rename plinth/tests/data/{plinth.config.with_missing_sections => configs/freedombox.config.with_missing_sections} (100%) diff --git a/conftest.py b/conftest.py index 89e0e455d..3f1eaf5ac 100644 --- a/conftest.py +++ b/conftest.py @@ -52,7 +52,7 @@ def fixture_load_cfg(): root_dir = pathlib.Path(__file__).resolve().parent test_data_dir = root_dir / 'plinth' / 'tests' / 'data' - cfg_file = test_data_dir / 'etc' / 'plinth' / 'plinth.config' + cfg_file = test_data_dir / 'configs' / 'freedombox.config' cfg.read_file(str(cfg_file)) yield cfg cfg.read_file(str(cfg_file)) diff --git a/plinth/__main__.py b/plinth/__main__.py index a6f2292cb..70f9e7580 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -105,7 +105,7 @@ def run_diagnostics_and_exit(): def adapt_config(arguments): - """Give commandline arguments precedence over plinth.config entries""" + """Give commandline arguments precedence over config entries""" for argument_name in precedence_commandline_arguments: argument_value = getattr(arguments, argument_name) if argument_value is not None: diff --git a/plinth/cfg.py b/plinth/cfg.py index b2ad72b42..75f8a7bc6 100644 --- a/plinth/cfg.py +++ b/plinth/cfg.py @@ -60,7 +60,7 @@ def get_develop_config_path(): def get_config_path(): """Get default config paths.""" - return '/etc/plinth/plinth.config' + return '/etc/freedombox/freedombox.config' def read(): diff --git a/plinth/tests/data/etc/plinth/plinth.config b/plinth/tests/data/configs/freedombox.config similarity index 100% rename from plinth/tests/data/etc/plinth/plinth.config rename to plinth/tests/data/configs/freedombox.config diff --git a/plinth/tests/data/plinth.config.with_missing_options b/plinth/tests/data/configs/freedombox.config.with_missing_options similarity index 100% rename from plinth/tests/data/plinth.config.with_missing_options rename to plinth/tests/data/configs/freedombox.config.with_missing_options diff --git a/plinth/tests/data/plinth.config.with_missing_sections b/plinth/tests/data/configs/freedombox.config.with_missing_sections similarity index 100% rename from plinth/tests/data/plinth.config.with_missing_sections rename to plinth/tests/data/configs/freedombox.config.with_missing_sections diff --git a/plinth/tests/test_cfg.py b/plinth/tests/test_cfg.py index 922a22354..f512df28a 100644 --- a/plinth/tests/test_cfg.py +++ b/plinth/tests/test_cfg.py @@ -14,11 +14,12 @@ import pytest from plinth import cfg TEST_CONFIG_DIR = \ - os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data') + os.path.join(os.path.dirname(os.path.realpath(__file__)), + 'data', 'configs') CONFIG_FILE_WITH_MISSING_OPTIONS = \ - os.path.join(TEST_CONFIG_DIR, 'plinth.config.with_missing_options') + os.path.join(TEST_CONFIG_DIR, 'freedombox.config.with_missing_options') CONFIG_FILE_WITH_MISSING_SECTIONS = \ - os.path.join(TEST_CONFIG_DIR, 'plinth.config.with_missing_sections') + os.path.join(TEST_CONFIG_DIR, 'freedombox.config.with_missing_sections') logging.disable(logging.CRITICAL) @@ -29,12 +30,15 @@ def test_read_default_config_file(): """Verify that the default config file can be read correctly.""" config_file = cfg.get_develop_config_path() - # Read the plinth.config file directly + # Read the freedombox.config file directly parser = configparser.ConfigParser( - defaults={'parent_dir': pathlib.Path(config_file).parent}) + defaults={ + 'parent_dir': pathlib.Path(config_file).parent, + 'parent_parent_dir': pathlib.Path(config_file).parent.parent + }) parser.read(config_file) - # Read the plinth.config file via the cfg module + # Read the freedombox.config file via the cfg module cfg.read_file(config_file) # Compare the two results @@ -81,9 +85,6 @@ def test_read_config_file_with_missing_options(): def compare_configurations(parser): """Compare two sets of configuration values.""" - # Note that the count of items within each section includes the number - # of default items (1, for 'root'). - assert len(parser.items('Path')) == 9 assert parser.get('Path', 'file_root') == cfg.file_root assert parser.get('Path', 'config_dir') == cfg.config_dir assert parser.get('Path', 'custom_static_dir') == cfg.custom_static_dir @@ -92,7 +93,6 @@ def compare_configurations(parser): assert parser.get('Path', 'actions_dir') == cfg.actions_dir assert parser.get('Path', 'doc_dir') == cfg.doc_dir - assert len(parser.items('Network')) == 6 assert parser.get('Network', 'host') == cfg.host assert int(parser.get('Network', 'port')) == cfg.port assert parser.get('Network', 'secure_proxy_ssl_header') == \ @@ -103,5 +103,5 @@ def compare_configurations(parser): assert isinstance(cfg.use_x_forwarded_host, bool) assert parser.get('Network', 'use_x_forwarded_host') == \ str(cfg.use_x_forwarded_host) - assert len(parser.items('Misc')) == 2 + assert parser.get('Misc', 'box_name') == cfg.box_name