Skip to content

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

tests: Update test_spiderfootdb

Brendan Coles0a1aa7b24fc7
diff --git a/sfdb.py b/sfdb.py
index 1c689722..085a9704 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -874,7 +874,7 @@ class SpiderFootDb:
Args:
instanceId (str): scan instance ID
- resultHashes (str): TBD
+ resultHashes (list): list of event hashes
fpFlag (int): false positive
Returns:
@@ -888,6 +888,9 @@ class SpiderFootDb:
if not isinstance(instanceId, str):
raise TypeError(f"instanceId is {type(instanceId)}; expected str()")
+ if not isinstance(resultHashes, list):
+ raise TypeError(f"resultHashes is {type(resultHashes)}; expected list()")
+
with self.dbhLock:
for resultHash in resultHashes:
qry = "UPDATE tbl_scan_results SET false_positive = ? WHERE \
@@ -1098,12 +1101,12 @@ class SpiderFootDb:
if not isinstance(sfEvent, SpiderFootEvent):
raise TypeError(f"sfEvent is {type(sfEvent)}; expected SpiderFootEvent()")
+ if not isinstance(sfEvent.generated, float):
+ raise TypeError(f"sfEvent.generated is {type(sfEvent.generated)}; expected float()")
+
if not sfEvent.generated:
raise ValueError("sfEvent.generated is empty")
- if not isinstance(sfEvent.generated, float):
- raise TypeError(f"generated is {type(generated)}; expected float()")
-
if not isinstance(sfEvent.eventType, str):
raise TypeError(f"sfEvent.eventType is {type(sfEvent.eventType,)}; expected str()")
diff --git a/test/unit/test_spiderfootdb.py b/test/unit/test_spiderfootdb.py
index 21b61610..4c715862 100644
--- a/test/unit/test_spiderfootdb.py
+++ b/test/unit/test_spiderfootdb.py
@@ -1,5 +1,5 @@
# test_spiderfootdb.py
-from sfdb import SpiderFootDb
+from sfdb import SpiderFootDb, SpiderFootEvent
import unittest
class TestSpiderFootDb(unittest.TestCase):
@@ -34,29 +34,33 @@ class TestSpiderFootDb(unittest.TestCase):
'__logstdout': False
}
- def test_init_invalid_args_should_raise(self):
+ def test_init_argument_opts_of_invalid_type_should_raise_TypeError(self):
"""
Test __init__(self, opts, init=False)
"""
- with self.assertRaises(TypeError) as cm:
- sfdb = SpiderFootDb(None)
-
- with self.assertRaises(TypeError) as cm:
- sfdb = SpiderFootDb([])
+ invalid_types = [None, "", list(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb = SpiderFootDb(invalid_type)
- def test_init_no_options_should_raise(self):
+ def test_init_argument_opts_with_empty_value_should_raise_ValueError(self):
"""
Test __init__(self, opts, init=False)
"""
with self.assertRaises(ValueError) as cm:
sfdb = SpiderFootDb(dict())
+ def test_init_argument_opts_with_empty_key___database_value_should_raise_ValueError(self):
+ """
+ Test __init__(self, opts, init=False)
+ """
with self.assertRaises(ValueError) as cm:
opts = dict()
- opts['example'] = 'example not-empty dict'
+ opts['__database'] = None
sfdb = SpiderFootDb(opts)
- def test_init(self):
+ def test_init_should_create_SpiderFootDb_object(self):
"""
Test __init__(self, opts, init=False)
"""
@@ -64,7 +68,7 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertIsInstance(sfdb, SpiderFootDb)
@unittest.skip("todo")
- def test_create(self):
+ def test_create_should_create_database_schema(self):
"""
Test create(self)
"""
@@ -72,7 +76,7 @@ class TestSpiderFootDb(unittest.TestCase):
sfdb.create()
self.assertEqual('TBD', 'TBD')
- def test_close(self):
+ def test_close_should_close_database_connection(self):
"""
Test close(self)
"""
@@ -96,7 +100,7 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertIsInstance(search_results, list)
self.assertFalse(search_results)
- def test_search_invalid_criteria_should_raise(self):
+ def test_search_argument_criteria_of_invalid_type_should_raise_TypeError(self):
"""
Test search(self, criteria, filterFp=False)
"""
@@ -108,6 +112,12 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
search_results = sfdb.search(invalid_type, False)
+ def test_search_argument_criteria_invalid_value_should_raise_ValueError(self):
+ """
+ Test search(self, criteria, filterFp=False)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
criteria = {
'scan_id': None,
'type': None,
@@ -118,7 +128,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(ValueError) as cm:
search_results = sfdb.search(criteria, False)
- def test_event_types_should_return_a_list(self):
+ def test_eventTypes_should_return_a_list(self):
"""
Test eventTypes(self)
"""
@@ -126,39 +136,41 @@ class TestSpiderFootDb(unittest.TestCase):
event_types = sfdb.eventTypes()
self.assertIsInstance(event_types, list)
- def test_scan_log_event(self):
+ def test_scanLogEvent_should_create_a_scan_log_event(self):
"""
Test scanLogEvent(self, instanceId, classification, message, component=None)
"""
sfdb = SpiderFootDb(self.default_options, False)
sfdb.scanLogEvent("", "", "", None)
- def test_scan_log_event_invalid_instance_id_should_raise(self):
+ self.assertEqual('TBD', 'TBD')
+
+ def test_scanLogEvent_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
"""
Test scanLogEvent(self, instanceId, classification, message, component=None)
"""
sfdb = SpiderFootDb(self.default_options, False)
- invalid_types = [None, list(), dict()]
+ invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
sfdb.scanLogEvent(invalid_type, "", "")
- def test_scan_log_event_invalid_classification_should_raise(self):
+ def test_scanLogEvent_argument_classification_of_invalid_type_should_raise_TypeError(self):
"""
Test scanLogEvent(self, instanceId, classification, message, component=None)
"""
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- invalid_types = [None, list(), dict()]
+ invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
sfdb.scanLogEvent(instance_id, invalid_type, "")
- def test_scan_log_event_invalid_message_should_raise(self):
+ def test_scanLogEvent_argument_message_of_invalid_type_should_raise_TypeError(self):
"""
Test scanLogEvent(self, instanceId, classification, message, component=None)
"""
@@ -172,16 +184,43 @@ class TestSpiderFootDb(unittest.TestCase):
sfdb.scanLogEvent(instance_id, "", invalid_type)
@unittest.skip("todo")
- def test_scan_instance_create(self):
+ def test_scanInstanceCreate_should_create_a_scan_instance(self):
+ """
+ Test scanInstanceCreate(self, instanceId, scanName, scanTarget)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ instance_id = "example instance id"
+ scan_name = "example scan name"
+ scan_target = "example scan target"
+
+ sfdb.scanInstanceCreate(instance_id, scan_name, scan_target)
+
+ self.assertEqual('TBD', 'TBD')
+
+ @unittest.skip("todo")
+ def test_scanInstanceCreate_argument_instanceId_already_exists_should_halt_and_catch_fire(self):
"""
Test scanInstanceCreate(self, instanceId, scanName, scanTarget)
"""
sfdb = SpiderFootDb(self.default_options, False)
- sfdb.scanInstanceCreate(None, None, None)
+
+ instance_id = "example instance id"
+ scan_name = "example scan name"
+ scan_target = "example scan target"
+
+ sfdb.scanInstanceCreate(instance_id, scan_name, scan_target)
+
+ instance_id = "example instance id"
+ scan_name = "example scan name"
+ scan_target = "example scan target"
+
+ with self.assertRaises(IOError) as cm:
+ sfdb.scanInstanceCreate(instance_id, scan_name, scan_target)
self.assertEqual('TBD', 'TBD')
- def test_scan_instance_create_invalid_instanceid_should_raise(self):
+ def test_scanInstanceCreate_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
"""
Test scanInstanceCreate(self, instanceId, scanName, scanTarget)
"""
@@ -195,7 +234,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
sfdb.scanInstanceCreate(invalid_type, scan_name, scan_target)
- def test_scan_instance_create_invalid_scan_name_should_raise(self):
+ def test_scanInstanceCreate_argument_scanName_of_invalid_type_should_raise_TypeError(self):
"""
Test scanInstanceCreate(self, instanceId, scanName, scanTarget)
"""
@@ -209,7 +248,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
sfdb.scanInstanceCreate(instance_id, invalid_type, scan_target)
- def test_scan_instance_create_invalid_scan_target_should_raise(self):
+ def test_scanInstanceCreate_argument_scanTarget_of_invalid_type_should_raise_TypeError(self):
"""
Test scanInstanceCreate(self, instanceId, scanName, scanTarget)
"""
@@ -223,7 +262,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
sfdb.scanInstanceCreate(instance_id, scan_name, invalid_type)
- def test_scan_instance_set(self):
+ def test_scanInstanceSet(self):
"""
Test scanInstanceSet(self, instanceId, started=None, ended=None, status=None)
"""
@@ -233,20 +272,66 @@ class TestSpiderFootDb(unittest.TestCase):
sfdb.scanInstanceSet(scan_instance, None, None, None)
self.assertEqual('TBD', 'TBD')
- @unittest.skip("todo")
- def test_scan_instance_get_should_return_a_list(self):
+ def test_scanInstanceSet_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanInstanceSet(self, instanceId, started=None, ended=None, status=None)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ started = None
+ ended = None
+ status = None
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_instance_set = sfdb.scanInstanceSet(invalid_type, started, ended, status)
+
+ def test_scanInstanceGet_should_return_scan_info(self):
"""
Test scanInstanceGet(self, instanceId)
"""
sfdb = SpiderFootDb(self.default_options, False)
- scan_instance = 'example scan instance'
- sfdb.scanInstanceSet(scan_instance, None, None, None)
+ instance_id = "example instance id"
+ scan_name = "example scan name"
+ scan_target = "example scan target"
+
+ sfdb.scanInstanceCreate(instance_id, scan_name, scan_target)
+
+ scan_instance_get = sfdb.scanInstanceGet(instance_id)
- scan_instance_get = sfdb.scanInstanceGet(scan_instance)
- self.assertIsInstance(scan_instance_get, list)
+ self.assertEqual(len(scan_instance_get), 6)
- def test_scan_result_summary_should_return_a_list(self):
+ self.assertIsInstance(scan_instance_get[0], str)
+ self.assertEqual(scan_instance_get[0], scan_name)
+
+ self.assertIsInstance(scan_instance_get[1], str)
+ self.assertEqual(scan_instance_get[1], scan_target)
+
+ self.assertIsInstance(scan_instance_get[2], float)
+
+ self.assertIsInstance(scan_instance_get[3], float)
+
+ self.assertIsInstance(scan_instance_get[4], float)
+
+ self.assertIsInstance(scan_instance_get[5], str)
+ self.assertEqual(scan_instance_get[5], 'CREATED')
+
+ def test_scanInstanceGet_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanInstanceGet(self, instanceId)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_instance_get = sfdb.scanInstanceGet(invalid_type)
+
+ def test_scanResultSummary_should_return_a_list(self):
"""
Test scanResultSummary(self, instanceId, by="type")
"""
@@ -256,29 +341,45 @@ class TestSpiderFootDb(unittest.TestCase):
scan_results_summary = sfdb.scanResultSummary(instance_id, "type")
self.assertIsInstance(scan_results_summary, list)
- def test_scan_result_summary_invalid_type_should_raise(self):
+ def test_scanResultSummary_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
"""
Test scanResultSummary(self, instanceId, by="type")
"""
sfdb = SpiderFootDb(self.default_options, False)
- invalid_types = [None, list(), dict()]
+ invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
scan_results_summary = sfdb.scanResultSummary(invalid_type)
+ def test_scanResultSummary_argument_by_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanResultSummary(self, instanceId, by="type")
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
instance_id = "example instance id"
- invalid_types = [None, list(), dict()]
+ invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_results_summary = sfdb.scanResultSummary(instance_id, None)
+ scan_results_summary = sfdb.scanResultSummary(instance_id, invalid_type)
+
+ with self.assertRaises(ValueError) as cm:
+ scan_results_summary = sfdb.scanResultSummary(instance_id, "invalid filter type")
+
+ def test_scanResultSummary_argument_by_invalid_value_should_raise_ValueError(self):
+ """
+ Test scanResultSummary(self, instanceId, by="type")
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+ instance_id = "example instance id"
with self.assertRaises(ValueError) as cm:
scan_results_summary = sfdb.scanResultSummary(instance_id, "invalid filter type")
- def test_scan_result_event_should_return_a_list(self):
+ def test_scanResultEvent_should_return_a_list(self):
"""
Test scanResultEvent(self, instanceId, eventType='ALL', filterFp=False)
"""
@@ -288,7 +389,22 @@ class TestSpiderFootDb(unittest.TestCase):
scan_result_event = sfdb.scanResultEvent(instance_id, "", False)
self.assertIsInstance(scan_result_event, list)
- def test_scan_result_event_invalid_event_type_should_raise(self):
+ def test_scanResultEvent_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanResultEvent(self, instanceId, eventType='ALL', filterFp=False)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ALL'
+ filter_fp = None
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanResultEvent(invalid_type, event_type, filter_fp)
+
+ def test_scanResultEvent_argument_eventType_of_invalid_type_should_raise_TypeError(self):
"""
Test scanResultEvent(self, instanceId, eventType='ALL', filterFp=False)
"""
@@ -301,7 +417,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
scan_result_event = sfdb.scanResultEvent(instance_id, invalid_type, None)
- def test_scan_result_event_unique_should_return_a_list(self):
+ def test_scanResultEventUnique_should_return_a_list(self):
"""
Test scanResultEventUnique(self, instanceId, eventType='ALL', filterFp=False)
"""
@@ -311,7 +427,22 @@ class TestSpiderFootDb(unittest.TestCase):
scan_result_event = sfdb.scanResultEventUnique(instance_id, "", False)
self.assertIsInstance(scan_result_event, list)
- def test_scan_result_event_unique_invalid_event_type_should_raise(self):
+ def test_scanResultEventUnique_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanResultEventUnique(self, instanceId, eventType='ALL', filterFp=False)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ALL'
+ filter_fp = None
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanResultEventUnique(invalid_type, event_type, filter_fp)
+
+ def test_scanResultEventUnique_argument_eventType_of_invalid_type_should_raise_TypeError(self):
"""
Test scanResultEventUnique(self, instanceId, eventType='ALL', filterFp=False)
"""
@@ -324,7 +455,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
scan_result_event = sfdb.scanResultEventUnique(instance_id, invalid_type, None)
- def test_scan_logs_should_return_a_list(self):
+ def test_scanLogs_should_return_a_list(self):
"""
Test scanLogs(self, instanceId, limit=None, fromRowId=None, reverse=False)
"""
@@ -336,7 +467,23 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
- def test_scan_errors(self):
+ def test_scanLogs_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanLogs(self, instanceId, limit=None, fromRowId=None, reverse=False)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ limit = None
+ from_row_id = None
+ reverse = None
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanLogs(invalid_type, limit, from_row_id, reverse)
+
+ def test_scanErrors_should_return_a_list(self):
"""
Test scanErrors(self, instanceId, limit=None)
"""
@@ -345,7 +492,20 @@ class TestSpiderFootDb(unittest.TestCase):
scan_instance = sfdb.scanErrors(instance_id, None)
self.assertIsInstance(scan_instance, list)
- def test_scan_instance_delete(self):
+ def test_scanErrors_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanErrors(self, instanceId, limit=None)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ limit = None
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanErrors(invalid_type, limit)
+
+ def test_scanInstanceDelete(self):
"""
Test scanInstanceDelete(self, instanceId)
"""
@@ -355,15 +515,66 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
+ def test_scanInstanceDelete_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanInstanceDelete(self, instanceId)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanInstanceDelete(invalid_type)
+
@unittest.skip("todo")
- def test_scan_results_update_fp(self):
+ def test_scanResultsUpdateFP(self):
"""
Test scanResultsUpdateFP(self, instanceId, resultHashes, fpFlag)
"""
+ sfdb = SpiderFootDb(self.default_options, False)
+
instance_id = "example instance id"
+ scan_name = "example scan name"
+ scan_target = "example scan target"
+
+ sfdb.scanInstanceCreate(instance_id, scan_name, scan_target)
+
+ result_hashes = None
+ fp_flag = None
+ sfdb.scanResultsUpdateFP(instance_id, result_hashes, fp_flag)
+
self.assertEqual('TBD', 'TBD')
- def test_config_set_should_set_config_opts(self):
+ def test_scanResultsUpdateFP_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanResultsUpdateFP(self, instanceId, resultHashes, fpFlag)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ result_hashes = []
+ fp_flag = None
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanResultsUpdateFP(invalid_type, result_hashes, fp_flag)
+
+ def test_scanResultsUpdateFP_argument_resultHashes_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanResultsUpdateFP(self, instanceId, resultHashes, fpFlag)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ instance_id = "example instance id"
+ fp_flag = None
+ invalid_types = [None, "", dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ sfdb.scanResultsUpdateFP(instance_id, invalid_type, fp_flag)
+
+ def test_configSet_should_set_config_opts(self):
"""
Test configSet(self, optMap=dict())
"""
@@ -376,7 +587,9 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertIsInstance(config, dict)
self.assertIn('example', config)
- def test_config_set_invalid_optmap_should_raise(self):
+ self.assertEqual('TBD', 'TBD')
+
+ def test_configSet_argument_optmap_of_invalid_type_should_raise_TypeError(self):
"""
Test configSet(self, optMap=dict())
"""
@@ -389,10 +602,7 @@ class TestSpiderFootDb(unittest.TestCase):
scan_result_event = sfdb.scanResultEventUnique("", invalid_type, None)
sfdb.configSet(invalid_type)
- with self.assertRaises(ValueError) as cm:
- sfdb.configSet(dict())
-
- def test_config_get_should_return_a_dict(self):
+ def test_configGet_should_return_a_dict(self):
"""
Test configGet(self)
"""
@@ -400,7 +610,7 @@ class TestSpiderFootDb(unittest.TestCase):
config = sfdb.configGet()
self.assertIsInstance(config, dict)
- def test_config_clear_should_clear_config(self):
+ def test_configClear_should_clear_config(self):
"""
Test configClear(self)
"""
@@ -420,22 +630,29 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertIsInstance(config, dict)
self.assertNotIn('example', config)
- def test_scan_config_set(self):
+ def test_scanConfigSet_argument_optMap_of_invalid_type_should_raise_TypeError(self):
"""
Test scanConfigSet(self, id, optMap=dict())
"""
sfdb = SpiderFootDb(self.default_options, False)
+ instance_id = "example instance id"
invalid_types = [None, ""]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfdb.scanConfigSet("", invalid_type)
+ sfdb.scanConfigSet(instance_id, invalid_type)
+
+ def test_scanConfigSet_argument_instanceId_with_empty_value_should_raise_ValueError(self):
+ """
+ Test scanConfigSet(self, id, optMap=dict())
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
with self.assertRaises(ValueError) as cm:
sfdb.scanConfigSet("", dict())
- def test_scan_config_get_should_return_a_dict(self):
+ def test_scanConfigGet_should_return_a_dict(self):
"""
Test scanConfigGet(self, instanceId)
"""
@@ -445,36 +662,494 @@ class TestSpiderFootDb(unittest.TestCase):
scan_config = sfdb.scanConfigGet(instance_id)
self.assertIsInstance(scan_config, dict)
- def test_scan_event_store_invalid_instanceid_should_raise(self):
+ def test_scanConfigGet_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanConfigGet(self, instanceId)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_config = sfdb.scanConfigGet(invalid_type)
+
+ def test_scanEventStore_should_store_a_scan_event(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ instance_id = "example instance id"
+ scan_event_store = sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
"""
Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
"""
sfdb = SpiderFootDb(self.default_options, False)
event = ""
- invalid_types = [None, list(), dict()]
+ invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
sfdb.scanEventStore(invalid_type, event)
+ def test_scanEventStore_argument_instanceId_with_empty_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event = ""
with self.assertRaises(ValueError) as cm:
sfdb.scanEventStore("", event)
- def test_scan_event_store_invalid_event_should_raise(self):
+ def test_scanEventStore_argument_sfEvent_of_invalid_type_should_raise_TypeError(self):
"""
Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
"""
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- invalid_types = [None, "", list(), dict()]
+ invalid_types = [None, "", list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
sfdb.scanEventStore(instance_id, invalid_type)
- def test_scan_instance_list_should_return_a_list(self):
+ def test_scanEventStore_argument_sfEvent_with_invalid_generated_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, "", list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.generated = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_generated_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ event.generated = float()
+
+ with self.assertRaises(ValueError) as cm:
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_eventType_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.eventType = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_eventType_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ event.eventType = ''
+
+ with self.assertRaises(ValueError) as cm:
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_data_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.data = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_data_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ event.data = ''
+
+ with self.assertRaises(ValueError) as cm:
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_module_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.module = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_module_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ event.module = ''
+ with self.assertRaises(ValueError) as cm:
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_confidence_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.confidence = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_confidence_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_values = [-1, 101]
+ for invalid_value in invalid_values:
+ with self.subTest(invalid_value=invalid_value):
+ with self.assertRaises(ValueError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.confidence = invalid_value
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_visibility_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.visibility = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_visibility_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_values = [-1, 101]
+ for invalid_value in invalid_values:
+ with self.subTest(invalid_value=invalid_value):
+ with self.assertRaises(ValueError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.visibility = invalid_value
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_risk_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.risk = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_risk_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_values = [-1, 101]
+ for invalid_value in invalid_values:
+ with self.subTest(invalid_value=invalid_value):
+ with self.assertRaises(ValueError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.risk = invalid_value
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_sourceEvent_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, "", list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.sourceEvent = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_invalid_sourceEventHash_property_type_should_raise_TypeError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+ event.sourceEventHash = invalid_type
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanEventStore_argument_sfEvent_with_empty_sourceEventHash_property_value_should_raise_ValueError(self):
+ """
+ Test scanEventStore(self, instanceId, sfEvent, truncateSize=0)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ module = ''
+ source_event = ''
+ source_event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ event_type = 'example event type'
+ event_data = 'example event data'
+ module = 'example module'
+ event = SpiderFootEvent(event_type, event_data, module, source_event)
+
+ instance_id = "example instance id"
+ event.sourceEventHash = ''
+ with self.assertRaises(ValueError) as cm:
+ sfdb.scanEventStore(instance_id, event)
+
+ def test_scanInstanceList_should_return_a_list(self):
"""
Test scanInstanceList(self)
"""
@@ -483,7 +1158,7 @@ class TestSpiderFootDb(unittest.TestCase):
scan_instances = sfdb.scanInstanceList()
self.assertIsInstance(scan_instances, list)
- def test_scan_result_history_should_return_a_list(self):
+ def test_scanResultHistory_should_return_a_list(self):
"""
Test scanResultHistory(self, instanceId)
"""
@@ -493,7 +1168,20 @@ class TestSpiderFootDb(unittest.TestCase):
scan_result_history = sfdb.scanResultHistory(instance_id)
self.assertIsInstance(scan_result_history, list)
- def test_scan_element_sources_direct_should_return_a_list(self):
+ def test_scanResultHistory_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanResultHistory(self, instanceId)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ instance_id = "example instance id"
+ invalid_types = [None, list(), dict()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_result_history = sfdb.scanResultHistory(invalid_type)
+
+ def test_scanElementSourcesDirect_should_return_a_list(self):
"""
Test scanElementSourcesDirect(self, instanceId, elementIdList)
"""
@@ -506,20 +1194,33 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
- def test_scan_element_sources_direct_invalid_instanceid_should_raise(self):
+ def test_scanElementSourcesDirect_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
"""
Test scanElementSourcesDirect(self, instanceId, elementIdList)
"""
sfdb = SpiderFootDb(self.default_options, False)
element_id_list = []
- invalid_types = [None, list(), dict()]
+ invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
scan_element_sources_direct = sfdb.scanElementSourcesDirect(invalid_type, element_id_list)
- def test_scan_element_children_direct_should_return_a_list(self):
+ def test_scanElementSourcesDirect_argument_elementIdList_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanElementSourcesDirect(self, instanceId, elementIdList)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ instance_id = "example instance id"
+ invalid_types = [None, "", dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_element_sources_direct = sfdb.scanElementSourcesDirect(instance_id, invalid_type)
+
+ def test_scanElementChildrenDirect_should_return_a_list(self):
"""
Test scanElementChildrenDirect(self, instanceId, elementIdList)
"""
@@ -531,7 +1232,20 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
- def test_scan_element_children_direct_invalid_element_id_list_should_raise(self):
+ def test_scanElementChildrenDirect_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanElementChildrenDirect(self, instanceId, elementIdList)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ element_id_list = []
+ invalid_types = [None, list(), dict(), int()]
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_element_children_direct = sfdb.scanElementChildrenDirect(invalid_type, element_id_list)
+
+ def test_scanElementChildrenDirect_argument_elementIdList_of_invalid_type_should_raise_TypeError(self):
"""
Test scanElementChildrenDirect(self, instanceId, elementIdList)
"""
@@ -544,37 +1258,58 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(TypeError) as cm:
scan_element_children_direct = sfdb.scanElementChildrenDirect(instance_id, invalid_type)
- @unittest.skip("todo")
- def test_scan_element_sources_all_should_return_a_list(self):
+ def test_scanElementSourcesAll_should_return_a_list(self):
"""
Test scanElementSourcesAll(self, instanceId, childData)
"""
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- child_data = []
+ child_data = ["example child", "example child"]
scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, child_data)
self.assertIsInstance(scan_element_sources_all, list)
self.assertEqual('TBD', 'TBD')
- def test_scan_element_sources_all_invalid_child_data_should_raise(self):
+ def test_scanElementSourcesAll_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanElementSourcesAll(self, instanceId, childData)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ invalid_types = [None, list(), dict(), int()]
+ child_data = []
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_element_sources_all = sfdb.scanElementSourcesAll(invalid_type, child_data)
+
+ def test_scanElementSourcesAll_argument_childData_of_invalid_type_should_raise_TypeError(self):
"""
Test scanElementSourcesAll(self, instanceId, childData)
"""
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- invalid_types = [None, "", dict()]
+ invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, invalid_type)
+ def test_scanElementSourcesAll_argument_childData_with_empty_value_should_raise_ValueError(self):
+ """
+ Test scanElementSourcesAll(self, instanceId, childData)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ instance_id = "example instance id"
+ child_data = []
+
with self.assertRaises(ValueError) as cm:
- scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, list())
+ scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, child_data)
- def test_scan_element_children_all_should_return_a_list(self):
+ def test_scanElementChildrenAll_should_return_a_list(self):
"""
Test scanElementChildrenAll(self, instanceId, parentIds)
"""
@@ -586,14 +1321,27 @@ class TestSpiderFootDb(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
- def test_scan_element_children_all_invalid_element_id_list_should_raise(self):
+ def test_scanElementChildrenAll_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
+ """
+ Test scanElementChildrenAll(self, instanceId, parentIds)
+ """
+ sfdb = SpiderFootDb(self.default_options, False)
+
+ invalid_types = [None, list(), dict(), int()]
+ parent_ids = []
+ for invalid_type in invalid_types:
+ with self.subTest(invalid_type=invalid_type):
+ with self.assertRaises(TypeError) as cm:
+ scan_element_children_all = sfdb.scanElementChildrenAll(invalid_type, parent_ids)
+
+ def test_scanElementChildrenAll_argument_parentIds_of_invalid_type_should_raise_TypeError(self):
"""
Test scanElementChildrenAll(self, instanceId, parentIds)
"""
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- invalid_types = [None, "", dict()]
+ invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm: