-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add pytest and fix import * Add actions test
- Loading branch information
1 parent
b715b6f
commit 501605e
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import json | ||
import generator | ||
from . import generator | ||
|
||
|
||
def generate_json(count, **kwargs): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ qrcode | |
pillow | ||
xmljson | ||
sphinx_rtd_theme | ||
matplotlib 2.0.2 | ||
matplotlib==2.0.2 | ||
pytest |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from io import StringIO | ||
from unittest import mock | ||
|
||
import smtplib | ||
import pytest | ||
|
||
from hackr.actions import email | ||
|
||
|
||
@mock.patch('smtplib.SMTP') | ||
def test_email(mock_smtp): | ||
message = 'Mail message' | ||
params = { | ||
'email': '[email protected]', | ||
'password': 'password', | ||
'to': '[email protected]', | ||
'subject': 'Test', | ||
} | ||
mock_smtp = mock.Mock() | ||
|
||
response = email(message, **params) | ||
|
||
assert response == 'Mail Sent Successfully' | ||
|
||
|
||
@mock.patch('smtplib.SMTP') | ||
def test_email_exception(mock_smtp): | ||
message = 'Mail message' | ||
params = { | ||
'email': '[email protected]', | ||
'password': 'password', | ||
'to': '[email protected]', | ||
'subject': 'Test', | ||
} | ||
|
||
instance = mock_smtp.return_value | ||
instance.ehlo.side_effect = smtplib.SMTPRecipientsRefused('Failed to sent mail.') | ||
response = email(message, **params) | ||
|
||
assert not response |