1+ # -*- coding: utf-8 -*-
2+
3+ import pytest
4+ import json
5+
6+ import MailboxValidator
7+
8+ def testinvalidapikey (global_data ):
9+ mbv = MailboxValidator .SingleValidation (global_data ["apikey" ])
10+ results = mbv .
ValidateEmail (
'[email protected] ' )
11+ assert results ['error_message' ] == 'API key not found.'
12+
13+ def testapikeyexist (global_data , capsys ):
14+ if (global_data ["apikey" ] == 'YOUR_API_KEY' ):
15+ with capsys .disabled ():
16+ print ("You could enter a MailboxValidator API Key in tests/conftest.py for real web service calling test." )
17+ print ("You could sign up for a free API key at https://www.mailboxvalidator.com/plans#api if you do not have one." )
18+ assert global_data ["apikey" ] == "YOUR_API_KEY"
19+ else :
20+ assert global_data ["apikey" ] != "YOUR_API_KEY"
21+
22+ def testvalidateemail (global_data ):
23+ mbv = MailboxValidator .SingleValidation (global_data ["apikey" ])
24+ results = mbv .
ValidateEmail (
'[email protected] ' )
25+ if (global_data ["apikey" ] == 'YOUR_API_KEY' ):
26+ assert results ['error_code' ] == "101"
27+ else :
28+ assert results ['status' ] == "False"
29+
30+ def testdisposableemail (global_data ):
31+ mbv = MailboxValidator .SingleValidation (global_data ["apikey" ])
32+ results = mbv .
DisposableEmail (
'[email protected] ' )
33+ if (global_data ["apikey" ] == 'YOUR_API_KEY' ):
34+ assert results ['error_code' ] == "101"
35+ else :
36+ assert results ['is_disposable' ] == "True"
37+
38+ def testfreeemail (global_data ):
39+ mbv = MailboxValidator .SingleValidation (global_data ["apikey" ])
40+ results = mbv .
FreeEmail (
'[email protected] ' )
41+ if (global_data ["apikey" ] == 'YOUR_API_KEY' ):
42+ assert results ['error_code' ] == "101"
43+ else :
44+ assert results ['is_free' ] == "False"
0 commit comments