def test_query_invalid_query_should_return_error(self): """ Test query(self, query) """ opts = self.default_options opts['__modules__'] = dict() sfwebui = SpiderFootWebUi(self.web_default_options, opts) query = sfwebui.query(None) self.assertIsInstance(query, dict) self.assertEqual("Invalid query.", query.get('error').get('message')) query = sfwebui.query("UPDATE 1") self.assertIsInstance(query, dict) self.assertEqual("Non-SELECTs are unpredictable and not recommended.", query.get('error').get('message'))
def test_query_should_perform_a_sql_query(self): """ Test query(self, query) """ opts = self.default_options opts['__modules__'] = dict() sfwebui = SpiderFootWebUi(opts) query = sfwebui.query("SELECT 12345") self.assertIsInstance(query, bytes) self.assertIn(b"12345", query)
def test_query_should_perform_sql_query(self): """ Test query(self, query) """ opts = self.default_options opts['__modules__'] = dict() sfwebui = SpiderFootWebUi(self.web_default_options, opts) select = "12345" query = sfwebui.query(f"SELECT {select}") self.assertIsInstance(query, list) self.assertEqual(len(query), 1) self.assertEqual(str(query[0].get(select)), str(select))