Coverage for mindsdb / integrations / handlers / gmail_handler / tests / test_gmail_handler.py: 0%

23 statements  

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

1from mindsdb.integrations.handlers.gmail_handler.gmail_handler import GmailHandler 

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

3import unittest 

4 

5 

6class EmailsTableTest(unittest.TestCase): 

7 @classmethod 

8 def setUpClass(cls): 

9 cls.kwargs = { 

10 "connection_data": { 

11 "credentials_file": "mindsdb/integrations/handlers/gmail_handler/credentials.json", 

12 "scopes": ['https://www.googleapis.com/auth/gmail.readonly'] 

13 } 

14 } 

15 

16 cls.handler = GmailHandler('test_gmail_handler', **cls.kwargs) 

17 

18 def test_0_check_connection(self): 

19 assert self.handler.check_connection() 

20 

21 def test_1_native_query_select(self): 

22 query = 'SELECT * FROM emails WHERE query = "alert from:*@google.com"' 

23 result = self.handler.native_query(query) 

24 assert result.type is RESPONSE_TYPE.TABLE 

25 

26 def test_2_get_tables(self): 

27 tables = self.handler.get_tables() 

28 assert tables.type is not RESPONSE_TYPE.ERROR 

29 

30 def test_3_get_columns(self): 

31 columns = self.handler.emails.get_columns() 

32 

33 expected_columns = [ 

34 'id', 

35 'message_id', 

36 'thread_id', 

37 'label_ids', 

38 'sender', 

39 'to', 

40 'date', 

41 'subject', 

42 'snippet', 

43 'body', 

44 ] 

45 

46 self.assertListEqual(columns, expected_columns) 

47 

48 

49if __name__ == '__main__': 

50 unittest.main()