From b8dfe1f1a6ff5efeecda295b6ca3267cfc95d985 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 14 Apr 2021 16:39:53 -0500 Subject: [PATCH] Change init_menu() to establish_settings() --- .../src/pgwui_TEMPLATE/pgwui_TEMPLATE.py.mak | 9 ++++---- .../TEMPLATE/tests/test_pgwui_TEMPLATE.py.mak | 22 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/pgwui_TEMPLATE.py.mak b/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/pgwui_TEMPLATE.py.mak index add135b..f9dafb3 100644 --- a/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/pgwui_TEMPLATE.py.mak +++ b/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/pgwui_TEMPLATE.py.mak @@ -1,4 +1,5 @@ -# Copyright (C) 2018, 2020 The Meme Factory, Inc. http://www.karlpinc.com/ +# Copyright (C) 2018, 2020, 2021 The Meme Factory, Inc. +# http://www.karlpinc.com/ # This file is part of ${component} # @@ -26,8 +27,8 @@ DEFAULT_${short_name.upper()}_ROUTE = '/${short_name}' DEFAULT_${short_name.upper()}_MENU_LABEL = '${short_name} -- Description of ${component}' -def init_menu(config): - '''Add default menu information into settings when they are not present +def establish_settings(config): + '''Add defaults to settings when they are not present ''' settings = config.get_settings() pgwui = settings.setdefault('pgwui', dict()) @@ -39,6 +40,6 @@ def init_menu(config): def includeme(config): '''Pyramid configuration for ${component} ''' - init_menu(config) + establish_settings(config) config.add_route(PGWUI_COMPONENT, DEFAULT_${short_name.upper()}_ROUTE) config.scan() diff --git a/src/pgwui_develop/TEMPLATE/tests/test_pgwui_TEMPLATE.py.mak b/src/pgwui_develop/TEMPLATE/tests/test_pgwui_TEMPLATE.py.mak index f18a2f4..84ae794 100644 --- a/src/pgwui_develop/TEMPLATE/tests/test_pgwui_TEMPLATE.py.mak +++ b/src/pgwui_develop/TEMPLATE/tests/test_pgwui_TEMPLATE.py.mak @@ -1,4 +1,5 @@ -# Copyright (C) 2019, 2020 The Meme Factory, Inc. http://www.karlpinc.com/ +# Copyright (C) 2019, 2020, 2021 The Meme Factory, Inc. +# http://www.karlpinc.com/ # This file is part of ${component}. # @@ -38,15 +39,15 @@ def test_${component.lower()}_is_pgwui_component(pgwui_component_entry_point): assert pgwui_component_entry_point('${component.lower()}') is True -# init_menu() +# establish_settings() @pytest.mark.unittest -def test_init_menu_default(): +def test_establish_settings_default(): '''The settings get the module's default value when no settings exist ''' with pyramid.testing.testConfig() as config: - ${component.lower()}.init_menu(config) + ${component.lower()}.establish_settings(config) new_settings = config.get_settings() assert new_settings['pgwui']['${component.lower()}']['menu_label'] \ @@ -54,7 +55,7 @@ def test_init_menu_default(): @pytest.mark.unittest -def test_init_menu_no_default(): +def test_establish_settings_no_default(): '''The settings keep their value when they exist ''' test_menu_label = 'test label' @@ -67,14 +68,15 @@ def test_init_menu_no_default(): sample_settings['pgwui']['${component.lower()}']['menu_label'] \ = test_menu_label - ${component.lower()}.init_menu(config) + ${component.lower()}.establish_settings(config) new_settings = config.get_settings() assert new_settings['pgwui']['${component.lower()}']['menu_label'] \ == test_menu_label -mock_init_menu = testing.make_mock_fixture(${component.lower()}, 'init_menu') +mock_establish_settings = testing.make_mock_fixture( + ${component.lower()}, 'establish_settings') # includeme() @@ -84,8 +86,8 @@ mock_scan = testing.instance_method_mock_fixture('scan') @pytest.mark.unittest -def test_includeme(mock_init_menu, mock_add_route, mock_scan): - '''init_menu, add_route, and scan are all called +def test_includeme(mock_establish_settings, mock_add_route, mock_scan): + '''establish_settings, add_route, and scan are all called ''' with pyramid.testing.testConfig() as config: mocked_add_route = mock_add_route(config) @@ -93,6 +95,6 @@ def test_includeme(mock_init_menu, mock_add_route, mock_scan): ${component.lower()}.includeme(config) - mock_init_menu.assert_called_once() + mock_establish_settings.assert_called_once() mocked_add_route.assert_called_once() mocked_scan.assert_called_once() -- 2.34.1