Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 20, 2025
1 parent 656729c commit 9dc9192
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 111 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
136 changes: 34 additions & 102 deletions primed/cdsa/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -192,10 +180,7 @@ def test_command_agreements_one_agreement_needs_action_email(self):
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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.
Expand All @@ -215,10 +200,7 @@ def test_command_agreements_one_agreement_error_email(self):
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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())
Expand All @@ -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)
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -302,10 +276,7 @@ def test_command_workspaces_one_workspace_needs_action_email(self):
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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.
Expand All @@ -325,10 +296,7 @@ def test_command_workspaces_one_workspace_error_email(self):
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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())
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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="[email protected]", 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)
Expand All @@ -431,9 +393,7 @@ def test_command_accessors_error_email(self):
)
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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.
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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="[email protected]", 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)
Expand All @@ -535,9 +489,7 @@ def test_command_uploaders_error_email(self):
)
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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.
Expand All @@ -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)
Expand All @@ -587,26 +529,16 @@ def test_needs_action_email(self):
out = StringIO()
call_command("run_cdsa_audit", "--no-color", email="[email protected]", 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)
Expand Down
Loading

0 comments on commit 9dc9192

Please sign in to comment.