Generates a host list of first-party trackers for ad-blocking.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1023B

  1. #!/usr/bin/env python3
  2. import database
  3. import os
  4. import logging
  5. import csv
  6. TESTS_DIR = 'tests'
  7. if __name__ == '__main__':
  8. DB = database.Database()
  9. log = logging.getLogger('tests')
  10. for filename in os.listdir(TESTS_DIR):
  11. log.info("")
  12. log.info("Running tests from %s", filename)
  13. path = os.path.join(TESTS_DIR, filename)
  14. with open(path, 'rt') as fdesc:
  15. reader = csv.DictReader(fdesc)
  16. for test in reader:
  17. log.info("Testing %s (%s)", test['url'], test['comment'])
  18. for white in test['white'].split(':'):
  19. if not white:
  20. continue
  21. if any(DB.get_domain(white)):
  22. log.error("False positive: %s", white)
  23. for black in test['black'].split(':'):
  24. if not black:
  25. continue
  26. if not any(DB.get_domain(black)):
  27. log.error("False negative: %s", black)