From 22dd86c8f2d27f05fe0a4eea325390b3887f89f8 Mon Sep 17 00:00:00 2001 From: amimas Date: Tue, 27 Feb 2024 22:47:51 -0500 Subject: [PATCH] style: update formatting using black --- .../processors/project/hooks_processor.py | 18 +++++++++++------- tests/acceptance/standard/test_hooks.py | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gitlabform/processors/project/hooks_processor.py b/gitlabform/processors/project/hooks_processor.py index 2b652d38e..ca38c55b6 100644 --- a/gitlabform/processors/project/hooks_processor.py +++ b/gitlabform/processors/project/hooks_processor.py @@ -38,7 +38,7 @@ def _process_configuration(self, project_and_group: str, configuration: dict): else: debug(f"Not deleting hook '{hook}', because it doesn't exist") continue - + # Process new hook creation if not hook_id: debug(f"Creating hook '{hook}'") @@ -49,7 +49,9 @@ def _process_configuration(self, project_and_group: str, configuration: dict): # Processing existing hook updates gl_hook: dict = hook_in_gitlab.asdict() if hook_in_gitlab else {} if self.is_hook_config_different(gl_hook, hook_config): - debug(f"The hook '{hook}' config is different from what's in gitlab OR it contains a token") + debug( + f"The hook '{hook}' config is different from what's in gitlab OR it contains a token" + ) debug(f"Updating hook '{hook}'") updated_hook: Dict[str, Any] = project.hooks.update( hook_id, hook_config @@ -67,11 +69,13 @@ def _process_configuration(self, project_and_group: str, configuration: dict): ) project.hooks.delete(gh.id) - def is_hook_config_different(self, config_in_gitlab, config_in_gitlabform): - ''' + def is_hook_config_different( + self, config_in_gitlab: dict, config_in_gitlabform: dict + ): + """ Compare two dictionary representing a webhook configuration and determine if they are different. - + GitLab's webhook data does not contain "token" as it is considered a secret. If GitLabForm config for a webhook contains a "token", the difference cannot be validated. So, an empty value for "token" is used as GitLab's webhook data, @@ -80,10 +84,10 @@ def is_hook_config_different(self, config_in_gitlab, config_in_gitlabform): Args: config_in_gitlab (dict): hook configuration in gitlab config_in_gitlabform (dict): hook configuration in gitlabform - + Returns: boolean: True if the two configs are different. Otherwise False. - ''' + """ if "token" in config_in_gitlabform: debug( f"The hook '{config_in_gitlabform['url']}' config includes a token. Diff between config vs gitlab cannot be confirmed" diff --git a/tests/acceptance/standard/test_hooks.py b/tests/acceptance/standard/test_hooks.py index 449d8efa4..ad5a12ff5 100644 --- a/tests/acceptance/standard/test_hooks.py +++ b/tests/acceptance/standard/test_hooks.py @@ -171,7 +171,10 @@ def test_hooks_delete(self, gl, project, urls, caplog): # The last hook configured for deletion but it was never setup in gitlab. # Ensure expected error message is reported. with caplog.at_level(logging.DEBUG): - assert f"Not deleting hook '{non_existent_hook_url}', because it doesn't exist" in caplog.text + assert ( + f"Not deleting hook '{non_existent_hook_url}', because it doesn't exist" + in caplog.text + ) def test_hooks_enforce(self, gl, group, project, urls): target = project.path_with_namespace