From b8f4db9078f1036ea5fbd842d6463de90727a23a Mon Sep 17 00:00:00 2001 From: androiddrew Date: Thu, 18 Jan 2018 16:07:48 -0500 Subject: [PATCH] initial commit --- .gitignore | 2 ++ HISTORY.md | 0 apistar_mail/__init__.py | 0 apistar_mail/mail.py | 39 +++++++++++++++++++++++++++++++ setup.py | 48 ++++++++++++++++++++++++++++++++++++++ tests/__init__.py | 0 tests/conftest.py | 0 tests/test_apistar_mail.py | 21 +++++++++++++++++ 8 files changed, 110 insertions(+) create mode 100644 HISTORY.md create mode 100644 apistar_mail/__init__.py create mode 100644 apistar_mail/mail.py create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_apistar_mail.py diff --git a/.gitignore b/.gitignore index 7f7cccc..44f3d6b 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,5 @@ docs/_build/ # PyBuilder target/ +# Pycharm +.idea/ diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..e69de29 diff --git a/apistar_mail/__init__.py b/apistar_mail/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apistar_mail/mail.py b/apistar_mail/mail.py new file mode 100644 index 0000000..64151e9 --- /dev/null +++ b/apistar_mail/mail.py @@ -0,0 +1,39 @@ +import email +import smtplib +import typing + + +class Connection: + """Handles connection to host""" + pass + + +class Attachment: + """Encapsulates file attachment information""" + pass + + +class Message: + """Encapsulates an email message""" + + def __init__(self, subject: str, + recipients: typing.List[str]=None): + self.subject = subject + self.recipients = recipients or [] + + def add_recipient(self, recipient: str): + assert isinstance(recipient, str) + self.recipients.append(recipient) + + +class _MailMixin: + pass + + +class _Mail: + pass + + +class Mail: + """Manages email messaging""" + pass diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..597f7b9 --- /dev/null +++ b/setup.py @@ -0,0 +1,48 @@ +from setuptools import setup, find_packages + +with open('README.md') as readme_file: + readme = readme_file.read() + +with open('HISTORY.md') as history_file: + history = history_file.read() + +requirements = [ + 'apistar', +] + +setup_requirements = [ + 'pytest-runner', +] + +test_requirements = [ + 'pytest', + 'coverage', +] + +setup( + name='apistar_mail', + version='0.1.1', + description="A simple email Component for APIStar", + long_description=readme + '\n\n' + history, + author="Drew Bednar", + author_email='drew@androiddrew.com', + url='https://github.com/androiddrew/apistar-mail', + packages=find_packages(include=['apistar_mail']), + include_package_data=True, + install_requires=requirements, + license="MIT license", + zip_safe=False, + keywords='apistar_mail', + classifiers=[ + 'Development Status :: 1 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ], + test_suite='tests', + tests_require=test_requirements, + setup_requires=setup_requirements, +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_apistar_mail.py b/tests/test_apistar_mail.py new file mode 100644 index 0000000..a124c67 --- /dev/null +++ b/tests/test_apistar_mail.py @@ -0,0 +1,21 @@ +from apistar_mail.mail import Message + + +def test_message_init(): + msg = Message(subject="subject", + recipients=['fake@example.com']) + assert msg.subject == "subject" + assert msg.recipients == ['fake@example.com'] + + +def test_empty_recipient_list_init(): + msg1 = Message(subject="subject") + assert msg1.recipients == [] + + +def test_add_recipient(): + msg1 = Message(subject="subject") + assert msg1.recipients == [] + msg1.add_recipient('fake@example.com') + assert len(msg1.recipients) == 1 + assert msg1.recipients[0] == 'fake@example.com' \ No newline at end of file