def test_scanResultHistory_argument_instanceId_of_invalid_type_should_raise_TypeError(self): """ Test scanResultHistory(self, instanceId) """ sfdb = SpiderFootDb(self.default_options, False) invalid_types = [None, list(), dict()] for invalid_type in invalid_types: with self.subTest(invalid_type=invalid_type): with self.assertRaises(TypeError): sfdb.scanResultHistory(invalid_type)
def test_scanResultHistory_should_return_a_list(self): """ Test scanResultHistory(self, instanceId) """ sfdb = SpiderFootDb(self.default_options, False) instance_id = "example instance id" scan_result_history = sfdb.scanResultHistory(instance_id) self.assertIsInstance(scan_result_history, list)
def scanhistory(self, id): """Historical data for a scan. Args: id (str): scan ID """ cherrypy.response.headers['Content-Type'] = "application/json; charset=utf-8" dbh = SpiderFootDb(self.config) try: scan_history = dbh.scanResultHistory(id) except Exception: scan_history = [] return json.dumps(scan_history).encode('utf-8')
def scanhistory(self, id): """Historical data for a scan. Args: id (str): scan ID Returns: str: scan history as JSON """ if not id: return self.jsonify_error('404', "No scan specified") dbh = SpiderFootDb(self.config) try: return dbh.scanResultHistory(id) except Exception: return []