Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test_module.py in email_verifier #29

Merged
merged 4 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/scripts/osint/email_verifier/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ class Runner(OsintRunner):
def __init__(self, logger: str = __name__):
super(Runner, self).__init__(logger)

@staticmethod
def email_verifier(email: str = "Unknown") -> bool or None:
if email is None:
return False
return verify_email(email)

@validate_kwargs(PossibleKeys.KEYS)
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error:
email = kwargs.get("email")
result = verify_email(email)
result = self.email_verifier(email)
if not result:
return ScriptResponse.success(
result=result, message=f"Sorry, email {email} does not exist"
Expand Down
59 changes: 59 additions & 0 deletions src/scripts/osint/email_verifier/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

from unittest import TestCase
from .module import Runner


class email_verifier_test(TestCase):
def setUp(self):
"""
Setup something before each test function
:return: None
"""
self.runner = Runner()

def test_create_runner(self):
"""
Test creation of the class instance
:return: None
"""
self.assertIsNotNone(self.runner)
self.assertIsInstance(self.runner, Runner)

def test_pass_false_argument(self):
"""
Test passing an false arguments
:return: False
"""
result = self.runner.run(email="john@gmail.com")
self.assertEqual(result.get("result"), False)
self.assertEqual(result.get("status"), "success")

def test_pass_true_argument(self):
"""
Test passing an true arguments
:return: True
"""
result = self.runner.run(email="Georgy@gmail.com")
self.assertEqual(result.get("result"), True)
self.assertEqual(result.get("status"), "success")

def test_no_arguments(self):
"""
Test passing no arguments
:return: False
"""
result = self.runner.run()
self.assertEqual(result.get("result"), False)
self.assertEqual(result.get("status"), "success")

def test_wrong_argument(self):
"""
Test case when we can't pass the validator (exception)
:return: None
"""

def exception_func():
self.runner.run(wrong_argument="john@gmail.com")

self.assertRaises(KeyError, exception_func)