Change init_menu() to establish_settings()
authorKarl O. Pinc <kop@karlpinc.com>
Wed, 14 Apr 2021 21:39:53 +0000 (16:39 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Thu, 15 Apr 2021 21:51:27 +0000 (16:51 -0500)
src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/pgwui_TEMPLATE.py.mak
src/pgwui_develop/TEMPLATE/tests/test_pgwui_TEMPLATE.py.mak

index add135b680deab77dc3b149ba5f03b3aa0d68abc..f9dafb3b7ab5ef3f6d6ea84649e43396f3a4c5c1 100644 (file)
@@ -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 defaultto 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()
index f18a2f4e4bd7fdc42e010d1c8b277f5c8dcec617..84ae7949edf77f022339192d1b98d21b96d3fc22 100644 (file)
@@ -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()