-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathtests.py
61 lines (59 loc) · 2.23 KB
/
tests.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
53
54
55
56
57
58
59
60
61
import unittest
from facebook import Facebook
from instagram import Instagram
from github import Github
from pinterest import Pinterest
from reddit import Reddit
from twitter import Twitter
from quora import Quora
from medium import Medium
import warnings
def ignore_warnings(test_func):
def do_test(self, *args, **kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore", ResourceWarning)
test_func(self, *args, **kwargs)
return do_test
class Tests_scrapers(unittest.TestCase):
@ignore_warnings
def test_facebook(self):
profile_data = Facebook.scrap('despotovicme','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),3,"If length is less than output was not expected")
@ignore_warnings
def test_instagram(self):
profile_data = Instagram.scrap('therock','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),6)
@ignore_warnings
def test_github(self):
profile_data = Github.scrap('shaikhsajid1111','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),4)
@ignore_warnings
def test_pinterest(self):
profile_data = Pinterest.scrap('ohjoy','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),12)
@ignore_warnings
def test_reddit(self):
profile_data = Reddit.scrap('AcanthocephalaTime52','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),6)
@ignore_warnings
def test_twitter(self):
profile_data = Twitter.scrap('asadowaisi','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),11)
@ignore_warnings
def test_quora(self):
profile_data = Quora.scrap('John-Cate-2','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),11)
@ignore_warnings
def test_medium(self):
profile_data = Medium.scrap('KeithSpencer','firefox')
self.assertIsInstance(profile_data,dict)
self.assertEqual(len(profile_data),6)
if __name__ == '__main__':
unittest.main()