Coverage for mindsdb / integrations / handlers / db2_handler / tests / test_db2_handler.py: 0%

27 statements  

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

1import unittest 

2from mindsdb.integrations.handlers.db2_handler.db2_handler import DB2Handler 

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

4 

5 

6class DB2HandlerTest(unittest.TestCase): 

7 @classmethod 

8 def setUpClass(cls): 

9 cls.kwargs = { 

10 "connection_data": { 

11 "host": "127.0.0.1", 

12 "port": "25000", 

13 "user": "db2admin", 

14 "password": "1234", 

15 "database": "Books", 

16 "schema_name": "db2admin", 

17 } 

18 } 

19 cls.handler = DB2Handler("test_db2_handler", **cls.kwargs) 

20 

21 def test_0_connect(self): 

22 self.handler.connect() 

23 

24 def test_1_drop_table(self): 

25 res = self.handler.query("DROP TABLE IF EXISTS LOVE") 

26 assert res.type is not RESPONSE_TYPE.ERROR 

27 

28 def test_2_create_table(self): 

29 res = self.handler.query("CREATE TABLE IF NOT EXISTS LOVE (LOVER varchar(20))") 

30 assert res.type is not RESPONSE_TYPE.ERROR 

31 

32 def test_3_get_tables(self): 

33 tables = self.handler.get_tables() 

34 assert tables.type is not RESPONSE_TYPE.ERROR 

35 

36 def test_4_select_query(self): 

37 query = "SELECT * FROM AUTHORS" 

38 result = self.handler.native_query(query) 

39 assert result.type is RESPONSE_TYPE.TABLE 

40 

41 def test_5_check_connection(self): 

42 self.handler.check_connection() 

43 

44 

45if __name__ == "__main__": 

46 unittest.main()