From 9dc9192be5bf18aa317f559e034d1919d0d89809 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 16:25:50 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/settings/base.py | 2 +- config/settings/production.py | 2 +- primed/cdsa/tests/test_commands.py | 136 ++++++++--------------------- primed/duo/models.py | 7 +- primed/primed_anvil/forms.py | 2 +- primed/users/adapters.py | 2 +- 6 files changed, 40 insertions(+), 111 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 7c7410a4..b0681519 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -264,7 +264,7 @@ LOGGING = { "version": 1, "disable_existing_loggers": False, - "formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s " "%(process)d %(thread)d %(message)s"}}, + "formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s"}}, "handlers": { "console": { "level": "DEBUG", diff --git a/config/settings/production.py b/config/settings/production.py index 53cbf7aa..cf0b538a 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -124,7 +124,7 @@ "()": "maintenance_mode.logging.RequireNotMaintenanceMode503", }, }, - "formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s " "%(process)d %(thread)d %(message)s"}}, + "formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s"}}, "handlers": { "mail_admins": { "level": "ERROR", diff --git a/primed/cdsa/tests/test_commands.py b/primed/cdsa/tests/test_commands.py index cb7eaf59..42d41449 100644 --- a/primed/cdsa/tests/test_commands.py +++ b/primed/cdsa/tests/test_commands.py @@ -113,17 +113,13 @@ def test_command_output_no_records(self): """Test command output.""" out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running SignedAgreement access audit... ok!\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 0\n" - ) + expected_output = "Running SignedAgreement access audit... ok!\n* Verified: 0\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) - expected_output = ( - "Running CDSAWorkspace access audit... ok!\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 0\n" - ) + expected_output = "Running CDSAWorkspace access audit... ok!\n* Verified: 0\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(expected_output, out.getvalue()) - expected_output = "Running Accessor audit... ok!\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 0\n" - expected_output = "Running Uploader audit... ok!\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 0\n" + expected_output = "Running Accessor audit... ok!\n* Verified: 0\n* Needs action: 0\n* Errors: 0\n" + expected_output = "Running Uploader audit... ok!\n* Verified: 0\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. @@ -134,9 +130,7 @@ def test_command_agreements_one_agreement_verified(self): factories.DataAffiliateAgreementFactory.create(is_primary=False) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running SignedAgreement access audit... ok!\n" "* Verified: 1\n" "* Needs action: 0\n" "* Errors: 0\n" - ) + expected_output = "Running SignedAgreement access audit... ok!\n* Verified: 1\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. self.assertEqual(len(mail.outbox), 0) @@ -147,10 +141,7 @@ def test_command_agreements_one_agreement_needs_action(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) expected_output = ( - "Running SignedAgreement access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running SignedAgreement access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:sag:all"), out.getvalue()) @@ -167,10 +158,7 @@ def test_command_agreements_one_agreement_error(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) expected_output = ( - "Running SignedAgreement access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 0\n" - "* Errors: 1\n" + "Running SignedAgreement access audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" ) self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:sag:all"), out.getvalue()) @@ -192,10 +180,7 @@ def test_command_agreements_one_agreement_needs_action_email(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) expected_output = ( - "Running SignedAgreement access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running SignedAgreement access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) # One message has been sent by default. @@ -215,10 +200,7 @@ def test_command_agreements_one_agreement_error_email(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) expected_output = ( - "Running SignedAgreement access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 0\n" - "* Errors: 1\n" + "Running SignedAgreement access audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" ) self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:sag:all"), out.getvalue()) @@ -234,9 +216,7 @@ def test_command_workspaces_one_workspace_verified(self): factories.CDSAWorkspaceFactory.create() out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running CDSAWorkspace access audit... ok!\n" "* Verified: 1\n" "* Needs action: 0\n" "* Errors: 0\n" - ) + expected_output = "Running CDSAWorkspace access audit... ok!\n* Verified: 1\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. self.assertEqual(len(mail.outbox), 0) @@ -252,10 +232,7 @@ def test_command_workspaces_one_workspace_needs_action(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) expected_output = ( - "Running CDSAWorkspace access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running CDSAWorkspace access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:workspaces:all"), out.getvalue()) @@ -272,10 +249,7 @@ def test_command_workspaces_one_workspace_error(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) expected_output = ( - "Running CDSAWorkspace access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 0\n" - "* Errors: 1\n" + "Running CDSAWorkspace access audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" ) self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:workspaces:all"), out.getvalue()) @@ -302,10 +276,7 @@ def test_command_workspaces_one_workspace_needs_action_email(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) expected_output = ( - "Running CDSAWorkspace access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running CDSAWorkspace access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) # One message has been sent by default. @@ -325,10 +296,7 @@ def test_command_workspaces_one_workspace_error_email(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) expected_output = ( - "Running CDSAWorkspace access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 0\n" - "* Errors: 1\n" + "Running CDSAWorkspace access audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" ) self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:workspaces:all"), out.getvalue()) @@ -344,7 +312,7 @@ def test_accessors_no_accessors(self): factories.DataAffiliateAgreementFactory.create(is_primary=False) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = "Running Accessor audit... ok!\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 0\n" + expected_output = "Running Accessor audit... ok!\n* Verified: 0\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. @@ -356,7 +324,7 @@ def test_command_accessors_verified(self): agreement.signed_agreement.accessors.add(UserFactory.create()) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = "Running Accessor audit... ok!\n" "* Verified: 1\n" "* Needs action: 0\n" "* Errors: 0\n" + expected_output = "Running Accessor audit... ok!\n* Verified: 1\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. self.assertEqual(len(mail.outbox), 0) @@ -368,9 +336,7 @@ def test_command_accessors_needs_action(self): agreement.signed_agreement.accessors.add(account.user) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running Accessor audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Accessor audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:accessors:all"), out.getvalue()) # Zero messages have been sent by default. @@ -384,9 +350,7 @@ def test_command_accessors_error(self): ) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running Accessor audit... problems found.\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 1\n" - ) + expected_output = "Running Accessor audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:accessors:all"), out.getvalue()) # Zero messages have been sent by default. @@ -412,9 +376,7 @@ def test_command_accessors_needs_action_email(self): agreement.signed_agreement.accessors.add(account.user) out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) - expected_output = ( - "Running Accessor audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Accessor audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # One message has been sent by default. self.assertEqual(len(mail.outbox), 1) @@ -431,9 +393,7 @@ def test_command_accessors_error_email(self): ) out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) - expected_output = ( - "Running Accessor audit... problems found.\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 1\n" - ) + expected_output = "Running Accessor audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:accessors:all"), out.getvalue()) # One message has been sent by default. @@ -448,7 +408,7 @@ def test_uploaders_no_uploaders(self): factories.DataAffiliateAgreementFactory.create(is_primary=False) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = "Running Uploader audit... ok!\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 0\n" + expected_output = "Running Uploader audit... ok!\n* Verified: 0\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. @@ -460,7 +420,7 @@ def test_command_uploaders_verified(self): agreement.uploaders.add(UserFactory.create()) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = "Running Uploader audit... ok!\n" "* Verified: 1\n" "* Needs action: 0\n" "* Errors: 0\n" + expected_output = "Running Uploader audit... ok!\n* Verified: 1\n* Needs action: 0\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # Zero messages have been sent by default. self.assertEqual(len(mail.outbox), 0) @@ -472,9 +432,7 @@ def test_command_uploaders_needs_action(self): agreement.uploaders.add(account.user) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running Uploader audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Uploader audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:uploaders:all"), out.getvalue()) # Zero messages have been sent by default. @@ -488,9 +446,7 @@ def test_command_uploaders_error(self): ) out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) - expected_output = ( - "Running Uploader audit... problems found.\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 1\n" - ) + expected_output = "Running Uploader audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:uploaders:all"), out.getvalue()) # Zero messages have been sent by default. @@ -516,9 +472,7 @@ def test_command_uploaders_needs_action_email(self): agreement.uploaders.add(account.user) out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) - expected_output = ( - "Running Uploader audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Uploader audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # One message has been sent by default. self.assertEqual(len(mail.outbox), 1) @@ -535,9 +489,7 @@ def test_command_uploaders_error_email(self): ) out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) - expected_output = ( - "Running Uploader audit... problems found.\n" "* Verified: 0\n" "* Needs action: 0\n" "* Errors: 1\n" - ) + expected_output = "Running Uploader audit... problems found.\n* Verified: 0\n* Needs action: 0\n* Errors: 1\n" self.assertIn(expected_output, out.getvalue()) self.assertIn(reverse("cdsa:audit:signed_agreements:uploaders:all"), out.getvalue()) # One message has been sent by default. @@ -555,26 +507,16 @@ def test_needs_action(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", stdout=out) expected_output = ( - "Running CDSAWorkspace access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running CDSAWorkspace access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) expected_output = ( - "Running SignedAgreement access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running SignedAgreement access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) - expected_output = ( - "Running Accessor audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Accessor audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) - expected_output = ( - "Running Uploader audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Uploader audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # No messages have been sent by default. self.assertEqual(len(mail.outbox), 0) @@ -587,26 +529,16 @@ def test_needs_action_email(self): out = StringIO() call_command("run_cdsa_audit", "--no-color", email="test@example.com", stdout=out) expected_output = ( - "Running CDSAWorkspace access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running CDSAWorkspace access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) expected_output = ( - "Running SignedAgreement access audit... problems found.\n" - "* Verified: 0\n" - "* Needs action: 1\n" - "* Errors: 0\n" + "Running SignedAgreement access audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" ) self.assertIn(expected_output, out.getvalue()) - expected_output = ( - "Running Accessor audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Accessor audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) - expected_output = ( - "Running Uploader audit... problems found.\n" "* Verified: 0\n" "* Needs action: 1\n" "* Errors: 0\n" - ) + expected_output = "Running Uploader audit... problems found.\n* Verified: 0\n* Needs action: 1\n* Errors: 0\n" self.assertIn(expected_output, out.getvalue()) # Two messages has been sent. self.assertEqual(len(mail.outbox), 4) diff --git a/primed/duo/models.py b/primed/duo/models.py index 558a1dfa..cc445724 100644 --- a/primed/duo/models.py +++ b/primed/duo/models.py @@ -101,12 +101,9 @@ def clean(self): if hasattr(self, "data_use_permission") and self.data_use_permission: if self.data_use_permission.requires_disease_term and not self.disease_term: raise ValidationError( - "`disease_term` must not be None " "because data_use_permission requires a disease restriction." + "`disease_term` must not be None because data_use_permission requires a disease restriction." ) if not self.data_use_permission.requires_disease_term and self.disease_term: raise ValidationError( - ( - "`disease_term` must be None " - "because data_use_permission does not require a disease restriction." - ) + ("`disease_term` must be None because data_use_permission does not require a disease restriction.") ) diff --git a/primed/primed_anvil/forms.py b/primed/primed_anvil/forms.py index bacb8e1a..fce754d9 100644 --- a/primed/primed_anvil/forms.py +++ b/primed/primed_anvil/forms.py @@ -16,5 +16,5 @@ def __init__(self, *args, **kwargs): if "authorization_domains" in self.fields: self.fields["authorization_domains"].disabled = True self.fields["authorization_domains"].help_text = ( - "An authorization domain will be automatically created " "using the name of the workspace." + "An authorization domain will be automatically created using the name of the workspace." ) diff --git a/primed/users/adapters.py b/primed/users/adapters.py index 12011304..5902a15f 100644 --- a/primed/users/adapters.py +++ b/primed/users/adapters.py @@ -32,7 +32,7 @@ def update_user_info(self, user, extra_data: Dict, apply_update=True): user_changed = False if user.name != full_name: logger.info( - f"[SocialAccountAdatpter:update_user_info] user {user} " f"name updated from {user.name} to {full_name}" + f"[SocialAccountAdatpter:update_user_info] user {user} name updated from {user.name} to {full_name}" ) user.name = full_name user_changed = True