From 959f80604a326579bc17cdf1e823bcbc37898efb Mon Sep 17 00:00:00 2001 From: Clemens Rieder <68914047+clemensrieder@users.noreply.github.com> Date: Thu, 12 Jan 2023 09:36:55 +0100 Subject: [PATCH] Remove try/except + test Changes in d064ff5 made try/except unnecessary and the subsequent test failed. --- src/paperless_mail/mail.py | 17 ++++++----------- src/paperless_mail/tests/test_mail.py | 5 ----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 4031f26d0..04caca63c 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -92,18 +92,13 @@ class TagMailAction(BaseMailAction): # The custom tag should look like "apple:" if "apple:" in parameter.lower(): - try: - _, self.color = parameter.split(":") - self.color = self.color.strip() - if not self.color.lower() in APPLE_MAIL_TAG_COLORS.keys(): - raise MailError("Not a valid AppleMail tag color.") - except Exception as e: - raise MailError( - """Could not parse parameters. - Make sure they look like this: apple: and - only use allowed colors.""", - ) from e + _, self.color = parameter.split(":") + self.color = self.color.strip() + + if not self.color.lower() in APPLE_MAIL_TAG_COLORS.keys(): + raise MailError("Not a valid AppleMail tag color.") + self.keyword = None else: diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 309e846d4..cd1001861 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -682,11 +682,6 @@ class TestMail(DirectoriesMixin, TestCase): TagMailAction, "apple:black", ) - self.assertRaises( - MailError, - TagMailAction, - "applegreen", - ) def test_handle_mail_account_tag_applemail(self): # all mails will be FLAGGED afterwards