Coverage for mindsdb / integrations / handlers / google_search_handler / tests / test_google_search_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.google_search_handler.google_search_handler import GoogleSearchConsoleHandler 

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

4 

5 

6class GoogleSearchConsoleHandlerTest(unittest.TestCase): 

7 

8 @classmethod 

9 def setUpClass(cls): 

10 cls.kwargs = { 

11 "connection_data": { 

12 "credentials": "/path/to/credentials.json" 

13 }, 

14 "file_storage": "/path/to/file_storage" 

15 } 

16 cls.handler = GoogleSearchConsoleHandler('test_google_search_console_handler', **cls.kwargs) 

17 

18 def test_0_check_connection(self): 

19 assert self.handler.check_connection() 

20 

21 def test_1_get_tables(self): 

22 tables = self.handler.get_tables() 

23 assert tables.type is not RESPONSE_TYPE.ERROR 

24 

25 def test_2_select_analytics_query(self): 

26 query = "SELECT clicks FROM my_console.Analytics WHERE siteUrl = " \ 

27 "'https://www.mindsdb.com' AND startDate = '2020-10-01' " \ 

28 "AND endDate = '2020-10-31'" 

29 result = self.handler.native_query(query) 

30 assert result.type is RESPONSE_TYPE.TABLE 

31 

32 def test_3_select_sitemaps_query(self): 

33 query = "SELECT type FROM my_console.Sitemaps WHERE siteUrl = " \ 

34 "'https://www.mindsdb.com' AND feedpath = " \ 

35 "'https://www.mindsdb.com/sitemap.xml'" 

36 result = self.handler.native_query(query) 

37 assert result.type is RESPONSE_TYPE.TABLE 

38 

39 def test_4_insert_sitemaps_query(self): 

40 query = "INSERT INTO my_console.Sitemaps VALUES " \ 

41 "('https://www.mindsdb.com/sitemap.xml'," \ 

42 "'https://www.mindsdb')" 

43 result = self.handler.native_query(query) 

44 assert result.type is RESPONSE_TYPE.TABLE 

45 

46 def test_5_delete_sitemaps_query(self): 

47 query = "DELETE FROM my_console.Sitemaps WHERE " \ 

48 "siteUrl = 'https://www.mindsdb' AND feedpath = " \ 

49 "'https://www.mindsdb.com/sitemap.xml'" 

50 result = self.handler.native_query(query) 

51 assert result.type is RESPONSE_TYPE.TABLE 

52 

53 

54if __name__ == '__main__': 

55 unittest.main()