Skip to content

Commit

Permalink
TST: Catch warnings in all bots, allow some
Browse files Browse the repository at this point in the history
fixes #1129
  • Loading branch information
Sebastian Wagner committed Jan 25, 2018
1 parent d15c45b commit afba389
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -102,6 +102,7 @@ Support for Python 3.3 has been dropped, it reached its end of life.

### Tests
- `tests/lib/test_pipeline`: Redis tests clear all queues before and after tests (#1086)
- Warnings are not allowed by default, an allowed count can be specified (#1129).

### Packaging
* cron jobs: fix paths of executables
Expand Down
1 change: 1 addition & 0 deletions intelmq/lib/test.py
Expand Up @@ -271,6 +271,7 @@ def run_bot(self, iterations: int=1, error_on_pipeline: bool=False, prepare=True
self.assertRegexpMatchesLog("INFO - Bot is starting.")
self.assertLoglineEqual(-1, "Bot stopped.", "INFO")
self.assertNotRegexpMatchesLog("(ERROR.*?){%d}" % (self.allowed_error_count + 1))
self.assertNotRegexpMatchesLog("(WARNING.*?){%d}" % (self.allowed_warning_count + 1))
self.assertNotRegexpMatchesLog("CRITICAL")
""" If no error happened (incl. tracebacks) we can check for formatting """
if not self.allowed_error_count:
Expand Down
Expand Up @@ -55,19 +55,22 @@ def set_bot(cls):

def test_ipv4_lookup(self):
self.input_message = EXAMPLE_INPUT
self.allowed_warning_count = 1
self.run_bot()
self.assertLogMatches(pattern="^The parameter 'query_ripe_stat' is deprecated and will be r",
levelname="WARNING")
self.assertMessageEqual(0, EXAMPLE_OUTPUT)

def test_ipv6_lookup(self):
self.input_message = EXAMPLE_INPUT6
self.allowed_warning_count = 1
self.run_bot()
self.assertMessageEqual(0, EXAMPLE_OUTPUT6)

def test_empty_lookup(self):
""" No email is returned, event should be untouched. """
self.input_message = EMPTY_INPUT
self.allowed_warning_count = 1
self.run_bot()
self.assertMessageEqual(0, EMPTY_INPUT)

Expand Down Expand Up @@ -104,6 +107,7 @@ def test_ripe_db_as_errors(self):
}
self.input_message = EXAMPLE_INPUT
self.allowed_error_count = 1
self.allowed_warning_count = 1
self.prepare_bot()
old = self.bot.URL_DB_AS
self.bot.URL_DB_AS = 'http://localhost/{}'
Expand All @@ -121,6 +125,7 @@ def test_ripe_db_ip_errors(self):
}
self.input_message = EXAMPLE_INPUT
self.allowed_error_count = 1
self.allowed_warning_count = 1
self.prepare_bot()
old = self.bot.URL_DB_IP
self.bot.URL_DB_IP = 'http://localhost/{}'
Expand Down
1 change: 1 addition & 0 deletions intelmq/tests/lib/test_bot.py
Expand Up @@ -43,6 +43,7 @@ def test_logging_catch_warnings(self):
Test if the logger catches warnings issued by the warnings module.
"""
self.input_message = test_parser_bot.EXAMPLE_SHORT
self.allowed_warning_count = 1
self.run_bot()
self.assertLogMatches(levelname='WARNING', pattern='.*intelmq/tests/lib/test_parser_bot\.py\:77\: UserWarning: This is a warning test.')

Expand Down
1 change: 1 addition & 0 deletions intelmq/tests/lib/test_parser_bot.py
Expand Up @@ -142,6 +142,7 @@ def test_event(self):
def test_missing_raw(self):
""" Test if correct Event has been produced. """
self.input_message = EXAMPLE_EMPTY_REPORT
self.allowed_warning_count = 1
self.run_bot()
self.assertAnyLoglineEqual(message='Report without raw field received. Possible '
'bug or misconfiguration in previous bots.',
Expand Down

0 comments on commit afba389

Please sign in to comment.