Skip to content

Commit e15f730

Browse files
[FIX] intelmqsetup correct bot-module names & BOT_FILE removed in test_conf
Signed-off-by: Sebastian Waldbauer <[email protected]>
1 parent 14310a5 commit e15f730

File tree

4 files changed

+2
-53
lines changed

4 files changed

+2
-53
lines changed

intelmq/bin/intelmqsetup.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,6 @@ def intelmqsetup_core(ownership=True, state_file=STATE_FILE_PATH):
120120
if ownership:
121121
change_owner(destination_file, owner='intelmq', group='intelmq', log=log_ownership_change)
122122

123-
if Path(BOTS_FILE).is_symlink():
124-
print('Skip writing BOTS file as it is a link.')
125-
else:
126-
print('Writing BOTS file.')
127-
shutil.copy(pkg_resources.resource_filename('intelmq', 'bots/BOTS'),
128-
BOTS_FILE)
129-
130123
if ownership:
131124
print('Setting intelmq as owner for it\'s directories.')
132125
for obj in (CONFIG_DIR, DEFAULT_LOGGING_PATH, ROOT_DIR, VAR_RUN_PATH,

intelmq/lib/upgrades.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ def v300_bots_file_removal(defaults, runtime, harmonization, dry_run):
608608
((2, 2, 1), (v221_feed_changes, )),
609609
((2, 2, 2), (v222_feed_changes, )),
610610
((2, 2, 3), ()),
611-
((2, 3, 0), (v230_csv_parser_parameter_fix_1, v230_feed_changes, v230_deprecations,)),
611+
((2, 3, 0), (v230_csv_parser_parameter_fix, v230_feed_changes, v230_deprecations,)),
612612
((3, 0, 0), (v300_bots_file_removal, ))
613613
])
614614

intelmq/tests/test_conf.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -98,51 +98,6 @@ def test_runtime_syntax(self):
9898
interpreted = json.loads(fcontent)
9999
self.assertEqual(to_json(interpreted), fcontent)
100100

101-
def test_bots(self):
102-
""" Test if BOTS has correct syntax and consistent content. """
103-
with open(pkg_resources.resource_filename('intelmq',
104-
'bots/BOTS')) as fhandle:
105-
fcontent = fhandle.read()
106-
107-
interpreted = json.loads(fcontent,
108-
object_pairs_hook=collections.OrderedDict)
109-
self.assertEqual(to_unsorted_json(interpreted), fcontent)
110-
111-
for groupname, group in interpreted.items():
112-
for bot_name, bot_config in group.items():
113-
for field in ['description', 'module', 'parameters']:
114-
self.assertIn(field, bot_config)
115-
importlib.import_module(bot_config['module'])
116-
117-
def test_modules_in_bots(self):
118-
""" Test if all bot modules are mentioned BOTS file. """
119-
with open(pkg_resources.resource_filename('intelmq',
120-
'bots/BOTS')) as fhandle:
121-
fcontent = fhandle.read()
122-
123-
interpreted = json.loads(fcontent,
124-
object_pairs_hook=collections.OrderedDict)
125-
modules = set()
126-
127-
for groupname, group in interpreted.items():
128-
for bot_name, bot_config in group.items():
129-
modules.add(bot_config['module'])
130-
131-
for _, groupname, _ in pkgutil.iter_modules(path=intelmq.bots.__path__):
132-
group = importlib.import_module('intelmq.bots.%s' % groupname)
133-
for _, providername, _ in pkgutil.iter_modules(path=group.__path__):
134-
modulename = 'intelmq.bots.%s.%s' % (groupname, providername)
135-
provider = importlib.import_module(modulename)
136-
for _, botname, _ in pkgutil.iter_modules(path=provider.__path__):
137-
classname = 'intelmq.bots.%s.%s.%s' % (groupname, providername, botname)
138-
self.assertFalse(classname not in modules and '_' in botname,
139-
msg="Bot %r not found in BOTS file." % classname)
140-
141-
for module in modules:
142-
bot = importlib.import_module(module)
143-
self.assertTrue(hasattr(bot, 'BOT'),
144-
msg='Module %r has no variable BOT.' % module)
145-
146101

147102
class CerberusTests(unittest.TestCase):
148103

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
base_path = Path(__file__).parent / 'intelmq/bots'
2525
botfiles = [botfile for botfile in Path(base_path).glob('**/*.py') if botfile.is_file() and not botfile.name.startswith('_')]
2626
for file in botfiles:
27+
file = Path(str(file).replace(str(base_path), 'intelmq/bots'))
2728
module = '.'.join(file.with_suffix('').parts)
2829
BOTS.append('{0} = {0}:BOT.run'.format(module))
2930

0 commit comments

Comments
 (0)