From 6b7f99939141afebbc88f5ec68a083fda738da4b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 7 Apr 2017 14:56:11 +0300 Subject: A rudimentary get_ids_from_message --- distixlib/__init__.py | 1 + distixlib/msg_id_extractor.py | 21 +++++++++++++++++++++ distixlib/msg_id_extractor_tests.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 distixlib/msg_id_extractor.py create mode 100644 distixlib/msg_id_extractor_tests.py diff --git a/distixlib/__init__.py b/distixlib/__init__.py index 8f0c20d..ee2471d 100644 --- a/distixlib/__init__.py +++ b/distixlib/__init__.py @@ -40,6 +40,7 @@ from .message_thread import MessageThread from .message_renderer import MessageRenderer from .repo import Repository from .git import Git +from .msg_id_extractor import get_ids_from_message from .text_renderer import TextRenderer from .html_renderer import HtmlRenderer from .util import get_ticket_ids diff --git a/distixlib/msg_id_extractor.py b/distixlib/msg_id_extractor.py new file mode 100644 index 0000000..cbe985d --- /dev/null +++ b/distixlib/msg_id_extractor.py @@ -0,0 +1,21 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + + +def get_ids_from_message(msg): + return [] diff --git a/distixlib/msg_id_extractor_tests.py b/distixlib/msg_id_extractor_tests.py new file mode 100644 index 0000000..6a7e259 --- /dev/null +++ b/distixlib/msg_id_extractor_tests.py @@ -0,0 +1,36 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import email +import unittest + +import distixlib + + +class GetIdFromMessageTests(unittest.TestCase): + + def test_returns_empty_list_if_no_ids(self): + msg = email.message_from_string('''\ +From: user@example.com +To: other@example.com +Subject: O, Romeo + +Wherefore art thou? +''') + + self.assertEqual(distixlib.get_ids_from_message(msg), []) -- cgit v1.2.1