SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
test: add initial tests for notify_listeners
Amr Awadad0af0efa1c7
diff --git a/tests/test_sflib.py b/tests/test_sflib.pyindex 0b0f8165..71051fab 100644--- a/tests/test_sflib.py+++ b/tests/test_sflib.py@@ -1,5 +1,5 @@import pytest-from sflib import SpiderFoot+from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEventclass TestSflib:@@ -52,3 +52,26 @@ class TestSflib:)assert parsed_links == expected_links+++class TestSfPlugin:+ def test_notify_listeners_works(self, mocker):+ """Tests when a module calls notifyListeners with an event,+ all listener modules have 'handleEvent' called"""++ mocked_fn = mocker.patch("sflib.SpiderFootPlugin.handleEvent")++ sf_plugin = SpiderFootPlugin()+ sf_plugin_2 = SpiderFootPlugin()+ sf_plugin.registerListener(listener=sf_plugin_2)++ root_event = SpiderFootEvent(+ eventType="ROOT",+ data=u'binarypool.com',+ module="",+ sourceEvent=None+ )++ sf_plugin.notifyListeners(sfEvent=root_event)+ mocked_fn.assert_called_once()+ mocked_fn.assert_called_with(root_event)\ No newline at end of file