parent
4a22054796
commit
c81be4825c
34
run_tests.py
Executable file
34
run_tests.py
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import database
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import csv
|
||||||
|
|
||||||
|
TESTS_DIR = 'tests'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
DB = database.Database()
|
||||||
|
log = logging.getLogger('tests')
|
||||||
|
|
||||||
|
for filename in os.listdir(TESTS_DIR):
|
||||||
|
log.info("")
|
||||||
|
log.info("Running tests from %s", filename)
|
||||||
|
path = os.path.join(TESTS_DIR, filename)
|
||||||
|
with open(path, 'rt') as fdesc:
|
||||||
|
reader = csv.DictReader(fdesc)
|
||||||
|
for test in reader:
|
||||||
|
log.info("Testing %s (%s)", test['url'], test['comment'])
|
||||||
|
|
||||||
|
for white in test['white'].split(':'):
|
||||||
|
if not white:
|
||||||
|
continue
|
||||||
|
if any(DB.get_domain(white)):
|
||||||
|
log.error("False positive: %s", white)
|
||||||
|
|
||||||
|
for black in test['black'].split(':'):
|
||||||
|
if not black:
|
||||||
|
continue
|
||||||
|
if not any(DB.get_domain(black)):
|
||||||
|
log.error("False negative: %s", black)
|
|
@ -1,6 +1,5 @@
|
||||||
url,white,black,comment
|
url,white,black,comment
|
||||||
https://support.apple.com,support.apple.com,,EdgeKey / AkamaiEdge
|
https://support.apple.com,support.apple.com,,EdgeKey / AkamaiEdge
|
||||||
https://www.pinterest.fr/,i.pinimg.com,,Cedexis
|
https://www.pinterest.fr/,i.pinimg.com,,Cedexis
|
||||||
https://www.pinterest.fr/,i.pinimg.com,,Cedexis
|
|
||||||
https://www.tumblr.com/,66.media.tumblr.com,,ChiCDN
|
https://www.tumblr.com/,66.media.tumblr.com,,ChiCDN
|
||||||
https://www.skype.com/fr/,www.skype.com,,TrafficManager
|
https://www.skype.com/fr/,www.skype.com,,TrafficManager
|
||||||
|
|
|
Loading…
Reference in a new issue