-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7768e23
commit c4b9df6
Showing
1 changed file
with
44 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
import json | ||
|
||
import MailboxValidator | ||
|
||
def testinvalidapikey(global_data): | ||
mbv = MailboxValidator.SingleValidation(global_data["apikey"]) | ||
results = mbv.ValidateEmail('example@example.com') | ||
assert results['error_message'] == 'API key not found.' | ||
|
||
def testapikeyexist(global_data, capsys): | ||
if (global_data["apikey"] == 'YOUR_API_KEY'): | ||
with capsys.disabled(): | ||
print ("You could enter a MailboxValidator API Key in tests/conftest.py for real web service calling test.") | ||
print ("You could sign up for a free API key at https://www.mailboxvalidator.com/plans#api if you do not have one.") | ||
assert global_data["apikey"] == "YOUR_API_KEY" | ||
else: | ||
assert global_data["apikey"] != "YOUR_API_KEY" | ||
|
||
def testvalidateemail(global_data): | ||
mbv = MailboxValidator.SingleValidation(global_data["apikey"]) | ||
results = mbv.ValidateEmail('example@example.com') | ||
if (global_data["apikey"] == 'YOUR_API_KEY'): | ||
assert results['error_code'] == "101" | ||
else: | ||
assert results['status'] == "False" | ||
|
||
def testdisposableemail(global_data): | ||
mbv = MailboxValidator.SingleValidation(global_data["apikey"]) | ||
results = mbv.DisposableEmail('example@example.com') | ||
if (global_data["apikey"] == 'YOUR_API_KEY'): | ||
assert results['error_code'] == "101" | ||
else: | ||
assert results['is_disposable'] == "True" | ||
|
||
def testfreeemail(global_data): | ||
mbv = MailboxValidator.SingleValidation(global_data["apikey"]) | ||
results = mbv.FreeEmail('example@example.com') | ||
if (global_data["apikey"] == 'YOUR_API_KEY'): | ||
assert results['error_code'] == "101" | ||
else: | ||
assert results['is_free'] == "False" |