Better test of validate_settings()
authorKarl O. Pinc <kop@karlpinc.com>
Sun, 28 Jun 2020 20:39:49 +0000 (15:39 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Sun, 28 Jun 2020 20:39:49 +0000 (15:39 -0500)
src/pgwui_server/__init__.py
tests/test___init__.py

index e6baaa73eb75cc5548d574f9df343b17ee680617..6708439a8928c7d5e37abb84a66dcd907def8e81 100644 (file)
@@ -192,7 +192,8 @@ def validate_literal_column_headings(errors, settings):
 def validate_settings(errors, settings, components):
     '''Be sure all settings validate
     '''
-    component_keys = ['pgwui.{}'.format(component) for component in components]
+    component_keys = ['pgwui.{}'.format(component)
+                      for component in components]
     for key in settings.keys():
         abort_on_bad_setting(errors, component_keys, key)
     validate_setting_values(errors, settings)
index 90d81539ef28c8795d5814130fb8ba8484ca1d4b..8eb3741f5d8c7e26ab02cc4faf0f655ab4834eeb 100644 (file)
@@ -312,17 +312,22 @@ mock_validate_literal_column_headings = testing.make_mock_fixture(
 def test_validate_settings(mock_abort_on_bad_setting,
                            mock_validate_setting_values,
                            mock_validate_hmac):
-    '''Calls abort_on_bad_setting() for each key in setting
+    '''Calls abort_on_bad_setting() for each key in setting,
+    with the proper list of config declaration names for the
+    plugin components
     '''
     settings = {'key1': 'value1',
                 'key2': 'value2'}
+    components = ['pgwui_server']
 
     errors = []
-    pgwui_server_init.validate_settings(errors, settings, [])
+    pgwui_server_init.validate_settings(errors, settings, components)
 
     assert mock_validate_setting_values.called
     assert mock_validate_hmac.called
     assert mock_abort_on_bad_setting.call_count == len(settings)
+    assert mock_abort_on_bad_setting.call_args[0][1] == \
+        ['pgwui.{}'.format(components[0])]
 
 
 mock_validate_settings = testing.make_mock_fixture(