|
12 | 12 | import json |
13 | 13 | import unittest |
14 | 14 | from os.path import dirname, join |
| 15 | +from pytest import raises |
15 | 16 |
|
16 | 17 | import intelmq.tests.bots.experts.domain_suffix.test_expert as domain_suffix_expert_test |
17 | 18 | from intelmq.bots.experts.domain_suffix.expert import DomainSuffixExpertBot |
18 | | -from intelmq.bots.experts.jinja.expert import JinjaExpertBot |
19 | 19 | from intelmq.bots.experts.taxonomy.expert import TaxonomyExpertBot |
20 | 20 | from intelmq.bots.experts.url.expert import URLExpertBot |
21 | | -from intelmq.lib.bot import BotLibSettings, Dict39 |
| 21 | +from intelmq.lib.bot import BotLibSettings, Dict39, ExpertBot |
22 | 22 | from intelmq.lib.message import Message, MessageFactory |
23 | 23 | from intelmq.tests.lib import test_parser_bot |
24 | 24 |
|
|
28 | 28 | 'source.urlpath': '/', |
29 | 29 | 'protocol.application': 'http', |
30 | 30 | 'protocol.transport': 'tcp'} |
31 | | -BOT_CONFIG_JINJA_FAILING = Dict39({ |
32 | | - 'fields': { |
33 | | - 'feed.url': "{{ error! msg['source.fqdn'] | upper }}" |
34 | | - } |
35 | | -}) |
| 31 | + |
| 32 | + |
| 33 | +class BrokenInitExpertBot(ExpertBot): |
| 34 | + def init(self): |
| 35 | + raise ValueError('This initialization intionally raises an error!') |
36 | 36 |
|
37 | 37 |
|
38 | 38 | def assertMessageEqual(actual, expected): |
@@ -94,14 +94,12 @@ def test_url_and_taxonomy(): |
94 | 94 | assert queues['output'] == [Dict39(EXAMPLE_DATA_URL_OUT) | {'classification.taxonomy': 'other', 'classification.type': 'undetermined'}] |
95 | 95 |
|
96 | 96 |
|
97 | | -def test_bot_exception_import(): |
| 97 | +def test_bot_exception_init(): |
98 | 98 | """ |
99 | 99 | When a bot raises an exception during Bot initialization |
100 | 100 | """ |
101 | | - try: |
102 | | - JinjaExpertBot('jinja', settings=BotLibSettings | BOT_CONFIG_JINJA_FAILING) |
103 | | - except: |
104 | | - pass |
| 101 | + with raises(ValueError): |
| 102 | + BrokenInitExpertBot('broken', settings=BotLibSettings) |
105 | 103 |
|
106 | 104 |
|
107 | 105 | def test_bot_multi_message(): |
|
0 commit comments