forked from chorsley/python-Wappalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
60 lines (44 loc) · 1.57 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
from unittest import TestCase
from httpretty import HTTPretty, httprettified
from Wappalyzer import WebPage, Wappalyzer
class WebPageTestCase(TestCase):
@httprettified
def test_new_from_url(self):
HTTPretty.register_uri(HTTPretty.GET, 'http://example.com/', body='snerble')
webpage = WebPage.new_from_url('http://example.com/')
self.assertEquals(webpage.html, 'snerble')
class WappalyzerTestCase(TestCase):
@httprettified
def test_latest(self):
HTTPretty.register_uri(HTTPretty.GET, 'https://raw.github.com/ElbertF/Wappalyzer/master/share/apps.json', body="""
{
"categories": {
"foo": "bar"
},
"apps": {
"blee": {}
}
}
""")
analyzer = Wappalyzer.latest()
self.assertEquals(analyzer.categories['foo'], 'bar')
self.assertIn('blee', analyzer.apps)
def test_analyze_no_apps(self):
analyzer = Wappalyzer(categories={}, apps={})
webpage = WebPage('http://example.com', '<html></html>', {})
detected_apps = analyzer.analyze(webpage)
self.assertEquals(detected_apps, set())
def test_get_implied_apps(self):
analyzer = Wappalyzer(categories={}, apps={
'a': {
'implies': 'b',
},
'b': {
'implies': 'c',
},
'c': {
'implies': 'a',
},
})
implied_apps = analyzer._get_implied_apps('a')
self.assertEquals(implied_apps, set(['a', 'b', 'c']))