-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
52 lines (41 loc) · 2.07 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# -*- coding: utf-8 -*-u
"""
Purpose : Some tests for the HaveiBeenPwnedApi class
To run the tests : $ python -m unittest -v test
"""
import unittest
from pwnedapi.pwnedapi import HaveIBeenPwnedApi
from pwnedapi.exception import NotValidEmail, BreachNotFound, UnvalidParameters
class TestHaveIBeenPwnedApi(unittest.TestCase):
@classmethod
def setUpClass(cls):
""" creating test data set for the test module """
cls.api = HaveIBeenPwnedApi()
def test_get_all_dataclasses(self):
dataclasses = self.api.get_all_dataclasses()
self.assertIn("Email addresses", dataclasses)
self.assertIn("Passwords", dataclasses)
self.assertIn("Usernames", dataclasses)
self.assertNotIn("Adobe", dataclasses)
def test_get_all_breaches_name(self):
breaches = self.api.get_all_breaches_name()
self.assertIn("AshleyMadison", breaches)
self.assertIn("Adobe", breaches)
self.assertNotIn("Google", breaches)
def test_get_breach(self):
self.assertEqual("AshleyMadison", self.api.get_breach("AshleyMadison")['Name'])
self.assertIsInstance(self.api.get_breach("AshleyMadison"), dict)
self.assertRaises(BreachNotFound, self.api.get_breach, "Google")
def test_regex_email(self):
self.assertIsNone(self.api.regex_email.match("tvhmxoleoubgmail.com"))
def test_check_email(self):
self.assertRaises(NotValidEmail, self.api.check_email, "tvhmxoleoubgmail.com")
def test_check_pastebin(self):
self.assertRaises(NotValidEmail, self.api.check_pastebin, "tvhmxoleoubgmail.com")