-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
executable file
·66 lines (58 loc) · 2.14 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
import sys, time, os, threading, unittest, pprint, subprocess
import feedparser
import tembozapp.feedfix, tembozapp.normalize, tembozapp.filters
class TestCase(unittest.TestCase):
def setUp(self):
pass
def test100_autodiscovery(self):
"""Test """
import tembozapp.autodiscovery
feed_url = tembozapp.autodiscovery.find('https://blog.majid.info/')
assert feed_url == 'https://blog.majid.info/index.xml'
feed_url = tembozapp.autodiscovery.find('https://greenwald.substack.com')
assert feed_url == 'https://greenwald.substack.com/feed', feed_url
feed_url = tembozapp.autodiscovery.find('https://www.calnewport.com/blog/')
assert feed_url == 'https://www.calnewport.com/blog/feed'
def test101_feedparser_exceptions(self):
for fn in os.listdir('bugfeed'):
f = open('bugfeed/' + fn, 'r')
d = f.read()
f.close()
feedparser.parse(d)
def test102_title_xss(self):
f = open('bugfeed/boingboing', 'r')
d = f.read()
f.close()
f = feedparser.parse(d)
i = [i for i in f.entries if '>' in i.title][0]
tembozapp.normalize.normalize(i, f, False)
assert '>' not in i.title
def test103_highlight(self):
uid = 0
for (kind, pat, s) in [
('title_word', 'cloud', "Sopra Steria gets £££££££s to manage cops' Oracle e-Biz suite in Oracle's cloud in Cleveland, UK"),
('title_word', 'gb', "Sopra Steria gets £££££££s to manage cops' Oracle e-Biz suite in Oracle's cloud in Cleveland, UK"),
]:
uid += 1
rule = tembozapp.filters.KeywordRule(
uid, None, pat, kind)
before = time.time()
s2 = rule.highlight_title(s)
after = time.time()
assert after - before < 1.0
assert s2 != s
assert '<span' in s2
def test104_relurl(self):
f = open('bugfeed/Ablogtowatch', 'r')
d = f.read()
f.close()
f = feedparser.parse(d)
i = [i for i in f.entries if 'Zenith Chronomaster Open' in i.title][0]
tembozapp.normalize.normalize(i, f, False)
pprint.pprint(i)
def suite():
suite = unittest.makeSuite(TestCase, 'test')
return suite
if __name__ == '__main__':
unittest.main()