def test_verify_test_run(self): """ Bad example of a unit test. This method verifies that with the test data everything is registered correctly in the db. :return: """ self.remove_archive_folders() ma = ModsecAudit(verbose=False, settings=settings) ma.set_exit_on_end(False) ma.init_db() self.empty_tables(ma) ma.main() ma.end() self.check_runstatus(ma) self.check_sites(ma) self.check_ips(ma) self.check_hits(ma) self.check_parse_errors(ma)
from ModsecAudit import ModsecAudit from settings import settings import traceback import sys __author__ = 'Tim Lund <*****@*****.**>' ma = ModsecAudit(verbose=True, settings=settings) if True: ma.init_db() ma.main() ma.end() else: # @todo fix this code so it dosn't conceal exceptions on errors. Sqlalchemy ones in particular try: ma.init_db() ma.main() except KeyboardInterrupt, e: pass except Exception, e: ma.print_color("An error occurred:", ma.COLOR_RED) ma.print_color("\t" + str(e.__class__), ma.COLOR_RED) ma.print_color("\t" + e.get_message(), ma.COLOR_RED) traceback.print_tb(sys.exc_traceback) finally: ma.end()