Coverage for mindsdb / integrations / handlers / libsql_handler / tests / test_libsql_handler.py: 0%

31 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-21 00:36 +0000

1import unittest 

2from mindsdb.integrations.handlers.libsql_handler.libsql_handler import LibSQLHandler 

3from mindsdb.api.executor.data_types.response_type import RESPONSE_TYPE 

4 

5 

6class LibSQLHandlerTest(unittest.TestCase): 

7 @classmethod 

8 def setUpClass(cls): 

9 cls.kwargs = { 

10 "database": "tests/test.db", 

11 } 

12 cls.handler = LibSQLHandler("test_libsql_handler", cls.kwargs) 

13 

14 def test_0_check_connection(self): 

15 assert self.handler.check_connection() 

16 

17 def test_1_create_table(self): 

18 query = "CREATE TABLE IF NOT EXISTS user (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)" 

19 result = self.handler.native_query(query) 

20 assert result.type is RESPONSE_TYPE.OK 

21 

22 def test_2_insert_rows(self): 

23 query = ( 

24 "INSERT OR IGNORE INTO user (name, age) VALUES ('Alice', 30), ('Bob', 25)" 

25 ) 

26 result = self.handler.native_query(query) 

27 print(result) 

28 assert result.type is RESPONSE_TYPE.OK 

29 

30 def test_3_native_query_select(self): 

31 query = "SELECT * FROM user" 

32 result = self.handler.native_query(query) 

33 assert result.type is RESPONSE_TYPE.TABLE 

34 

35 def test_4_get_tables(self): 

36 tables = self.handler.get_tables() 

37 assert tables.type is not RESPONSE_TYPE.ERROR 

38 

39 def test_5_get_columns(self): 

40 columns = self.handler.get_columns("user") 

41 assert columns.type is not RESPONSE_TYPE.ERROR 

42 

43 

44if __name__ == "__main__": 

45 unittest.main()