Coverage for mindsdb / integrations / handlers / strapi_handler / tests / test_strapi_handler.py: 0%

30 statements  

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

1import unittest 

2from mindsdb.integrations.handlers.strapi_handler.strapi_handler import StrapiHandler 

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

4 

5 

6class StrapiHandlerTest(unittest.TestCase): 

7 

8 @classmethod 

9 def setUpClass(cls): 

10 connection_data = { 

11 'host': 'localhost', 

12 'port': '1337', 

13 'api_token': 'c56c000d867e95848c', 

14 'plural_api_ids': ['products', 'sellers']} 

15 cls.handler = StrapiHandler(name='myshop', connection_data=connection_data) 

16 

17 def test_0_check_connection(self): 

18 # Ensure the connection is successful 

19 self.assertTrue(self.handler.check_connection()) 

20 

21 def test_1_get_table(self): 

22 assert self.handler.get_tables() is not RESPONSE_TYPE.ERROR 

23 

24 def test_2_get_columns(self): 

25 assert self.handler.get_columns('products') is not RESPONSE_TYPE.ERROR 

26 

27 def test_3_get_data(self): 

28 # Ensure that you can retrieve data from a table 

29 data = self.handler.native_query('SELECT * FROM products') 

30 assert data.type is not RESPONSE_TYPE.ERROR 

31 

32 def test_4_get_data_with_condition(self): 

33 # Ensure that you can retrieve data with a condition 

34 data = self.handler.native_query('SELECT * FROM products WHERE id = 1') 

35 assert data.type is not RESPONSE_TYPE.ERROR 

36 

37 def test_5_insert_data(self): 

38 # Ensure that data insertion is successful 

39 query = "INSERT INTO myshop.sellers (name, email, sellerid) VALUES ('Ram', 'ram@gmail.com', 'ramu4')" 

40 result = self.handler.native_query(query) 

41 self.assertTrue(result) 

42 

43 def test_6_update_data(self): 

44 # Ensure that data updating is successful 

45 query = "UPDATE products SET name = 'test2' WHERE id = 1" 

46 result = self.handler.native_query(query) 

47 self.assertTrue(result) 

48 

49 

50if __name__ == '__main__': 

51 unittest.main()