Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

tests: modules: test handleEvent returns event (#1089)

bcoles751a65b89170
diff --git a/test/unit/modules/test_sfp_bitcoin.py b/test/unit/modules/test_sfp_bitcoin.py
index c42cd4bf..6b7f50e6 100644
--- a/test/unit/modules/test_sfp_bitcoin.py
+++ b/test/unit/modules/test_sfp_bitcoin.py
@@ -74,6 +74,8 @@ class TestModuleBitcoin(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_bitcoin)
event_type = 'ROOT'
@@ -82,9 +84,11 @@ class TestModuleBitcoin(unittest.TestCase):
source_event = ''
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_event_data_not_containing_bitcoin_string_should_not_return_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_countryname.py b/test/unit/modules/test_sfp_countryname.py
index 9ed44447..53308d80 100644
--- a/test/unit/modules/test_sfp_countryname.py
+++ b/test/unit/modules/test_sfp_countryname.py
@@ -74,6 +74,8 @@ class TestModuleCountryName(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_countryname)
event_type = 'ROOT'
@@ -88,9 +90,10 @@ class TestModuleCountryName(unittest.TestCase):
source_event = evt
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
- self.assertIsNone(result)
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_domain_whois_event_data_not_containing_countryname_string_should_not_create_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_creditcard.py b/test/unit/modules/test_sfp_creditcard.py
index eefc9055..e4e2829a 100644
--- a/test/unit/modules/test_sfp_creditcard.py
+++ b/test/unit/modules/test_sfp_creditcard.py
@@ -74,6 +74,8 @@ class TestModuleCreditCard(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_creditcard)
event_type = 'ROOT'
@@ -82,9 +84,11 @@ class TestModuleCreditCard(unittest.TestCase):
source_event = ''
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_event_data_not_containing_creditcard_string_should_not_return_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_errors.py b/test/unit/modules/test_sfp_errors.py
index 2d46151b..e4f3e28b 100644
--- a/test/unit/modules/test_sfp_errors.py
+++ b/test/unit/modules/test_sfp_errors.py
@@ -140,6 +140,8 @@ class TestModuleErrors(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_errors)
event_type = 'ROOT'
@@ -149,6 +151,7 @@ class TestModuleErrors(unittest.TestCase):
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
result = module.handleEvent(evt)
+ self.assertIsNone(result)
event_type = 'TARGET_WEB_CONTENT'
event_data = 'example data Internal Server Error example data'
@@ -157,9 +160,11 @@ class TestModuleErrors(unittest.TestCase):
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
evt.actualSource = 'https://spiderfoot.net/'
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_event_data_not_containing_error_string_should_not_return_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_ethereum.py b/test/unit/modules/test_sfp_ethereum.py
index b4addece..fe2d47b1 100644
--- a/test/unit/modules/test_sfp_ethereum.py
+++ b/test/unit/modules/test_sfp_ethereum.py
@@ -74,6 +74,8 @@ class TestModuleEthereum(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_ethereum)
event_type = 'ROOT'
@@ -82,9 +84,11 @@ class TestModuleEthereum(unittest.TestCase):
source_event = ''
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_event_data_not_containing_ethereum_string_should_not_return_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_hashes.py b/test/unit/modules/test_sfp_hashes.py
index 89a01038..64a72b72 100644
--- a/test/unit/modules/test_sfp_hashes.py
+++ b/test/unit/modules/test_sfp_hashes.py
@@ -74,6 +74,8 @@ class TestModuleHashes(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_hashes)
event_type = 'ROOT'
@@ -82,9 +84,11 @@ class TestModuleHashes(unittest.TestCase):
source_event = ''
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_event_data_not_containing_hashes_string_should_not_return_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_hosting.py b/test/unit/modules/test_sfp_hosting.py
index 83af448d..7ce2789a 100644
--- a/test/unit/modules/test_sfp_hosting.py
+++ b/test/unit/modules/test_sfp_hosting.py
@@ -75,6 +75,8 @@ class TestModuleHosting(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_hosting)
event_type = 'ROOT'
@@ -83,9 +85,11 @@ class TestModuleHosting(unittest.TestCase):
source_event = ''
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
@unittest.skip("todo")
def test_handleEvent_event_data_ip_address_not_hosted_should_not_return_event(self):
diff --git a/test/unit/modules/test_sfp_iban.py b/test/unit/modules/test_sfp_iban.py
index f66b6247..ca85743f 100644
--- a/test/unit/modules/test_sfp_iban.py
+++ b/test/unit/modules/test_sfp_iban.py
@@ -74,6 +74,8 @@ class TestModuleIban(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_iban)
event_type = 'ROOT'
@@ -82,9 +84,11 @@ class TestModuleIban(unittest.TestCase):
source_event = ''
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
- self.assertIsNone(result)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
+
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_event_data_not_containing_iban_string_should_not_return_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_phone.py b/test/unit/modules/test_sfp_phone.py
index b8ec7d2d..62171503 100644
--- a/test/unit/modules/test_sfp_phone.py
+++ b/test/unit/modules/test_sfp_phone.py
@@ -74,6 +74,8 @@ class TestModulePhone(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_phone)
event_type = 'ROOT'
@@ -88,9 +90,10 @@ class TestModulePhone(unittest.TestCase):
source_event = evt
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
- result = module.handleEvent(evt)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
- self.assertIsNone(result)
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_domain_whois_event_data_not_containing_phone_string_should_not_create_event(self):
sf = SpiderFoot(self.default_options)
diff --git a/test/unit/modules/test_sfp_webframework.py b/test/unit/modules/test_sfp_webframework.py
index 53edd2b0..a6266834 100644
--- a/test/unit/modules/test_sfp_webframework.py
+++ b/test/unit/modules/test_sfp_webframework.py
@@ -74,6 +74,8 @@ class TestModuleWebFramework(unittest.TestCase):
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")
+ raise Exception("OK")
+
module.notifyListeners = new_notifyListeners.__get__(module, sfp_webframework)
event_type = 'ROOT'
@@ -89,9 +91,10 @@ class TestModuleWebFramework(unittest.TestCase):
evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
evt.actualSource = "https://spiderfoot.net/"
- result = module.handleEvent(evt)
+ with self.assertRaises(Exception) as cm:
+ module.handleEvent(evt)
- self.assertIsNone(result)
+ self.assertEqual("OK", str(cm.exception))
def test_handleEvent_domain_whois_event_data_not_containing_webframework_string_should_not_create_event(self):
sf = SpiderFoot(self.default_options)