Skip to content

Commit

Permalink
Adding more tests and splitting up requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
abkfenris committed Oct 1, 2017
1 parent 28f8da7 commit bad6bc9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ python:
- 3.4
- 3.3
- 2.7
- 2.6
script: tox
10 changes: 4 additions & 6 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ pip==8.1.2
bumpversion==0.5.3
wheel==0.29.0
watchdog==0.8.3
flake8==2.6.0
tox==2.3.1
coverage==4.1
Sphinx==1.4.8
sphinxcontrib-napoleon
cryptography==1.7
PyYAML==3.11
pytest==2.9.2
pytest-runner==2.11.1


-r requirements_test.txt
-r requirements_docs.txt
1 change: 1 addition & 0 deletions requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinxcontrib-napoleon
5 changes: 5 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest==2.9.2
pytest-runner==2.11.1
flake8==2.6.0
tox==2.3.1
coverage==4.1
61 changes: 47 additions & 14 deletions tests/test_email_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,53 @@
import pytest


from email_to import email_to
import email_to


@pytest.fixture
def response():
"""Sample pytest fixture.
See more at: http://doc.pytest.org/en/latest/fixture.html
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')


def test_content(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
def message():
""" Simple message """
msg = email_to.Message('# A Test Message', style='h1 { color: blue }')
msg.add('This message is only a test of the alert system')
return msg


def test_build_message(message):
""" Test that a message can be created and added to directly """
msg = message

msg_string = str(msg)
assert '# A Test Message' in msg_string
assert 'This message is only a test of the alert system' in msg_string

msg_html = msg.html
assert '<html>' in msg_html
assert '<head></head>' in msg_html
assert '<body>' in msg_html
assert 'style="color:blue">' in msg_html
assert 'A Test Message' in msg_html
assert '<p>This message is only a test of the alert system' in msg_html


def test_empty_message():
""" Test that a message passed an empty body gets created """
msg = email_to.Message()
msg_string = str(msg)
assert msg_string == ''

msg_html = msg.html
assert msg.html == ''


def test_message_mime(message):
""" Test that a message can form a valid MIMEMultiPart object """
mime = message.mime()
mime_string = str(mime)
assert 'Content-Type' in mime_string
assert 'multipart/alternative' in mime_string
#assert 'From' in mime_string
assert 'MIME-Version:' in mime_string
assert 'Content-Type: text/plain; charset="us-ascii"' in mime_string
assert '# A Test Message' in mime_string
assert 'Content-Type: text/html; charset="us-ascii"' in mime_string
assert '<h1 style="color:blue">A Test Message</h1>' in mime_string
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands=flake8 email_to
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
-r{toxinidir}/requirements_test.txt
commands =
pip install -U pip
py.test --basetemp={envtmpdir}
Expand Down

0 comments on commit bad6bc9

Please sign in to comment.