Coverage for mindsdb / integrations / handlers / notion_handler / tests / test_notion_handler.py: 0%

38 statements  

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

1import unittest 

2 

3from mindsdb_sql_parser import parse_sql 

4 

5from mindsdb.integrations.handlers.notion_handler.notion_handler import NotionHandler 

6from mindsdb.integrations.handlers.notion_handler.notion_table import ( 

7 NotionDatabaseTable, 

8 NotionBlocksTable, 

9 NotionCommentsTable, 

10 NotionPagesTable, 

11) 

12 

13 

14class NotionHandlerTest(unittest.TestCase): 

15 @classmethod 

16 def setUpClass(cls): 

17 cls.kwargs = { 

18 "connection_data": { 

19 "api_token": "secret_KHTlOzUN5fIwVlb1euOpBa4lwcJA7jEALoBGDRrlATx" 

20 } 

21 } 

22 cls.handler = NotionHandler("test_notion_handler", **cls.kwargs) 

23 cls.db_table = NotionDatabaseTable(cls.handler) 

24 cls.pages_table = NotionPagesTable(cls.handler) 

25 cls.blocks_table = NotionBlocksTable(cls.handler) 

26 cls.comments_table = NotionCommentsTable(cls.handler) 

27 

28 def test_check_connection(self): 

29 status = self.handler.check_connection() 

30 self.assertTrue(status.success) 

31 

32 def test_select_database(self): 

33 query = "SELECT * FROM database WHERE database_id = '21510b8a953c4d62958c9907f3cf9f87'" 

34 ast = parse_sql(query) 

35 res = self.db_table.select(ast) 

36 self.assertFalse(res.empty) 

37 

38 def test_select_page(self): 

39 query = "SELECT * FROM pages WHERE page_id = '70f28e55416b4dfe8588aa175ecae63a'" 

40 ast = parse_sql(query) 

41 res = self.pages_table.select(ast) 

42 self.assertFalse(res.empty) 

43 

44 def test_select_blocks(self): 

45 query = ( 

46 "SELECT * FROM blocks WHERE block_id = '6d1480e0bf4b46e1a71be093f105d654'" 

47 ) 

48 ast = parse_sql(query) 

49 res = self.blocks_table.select(ast) 

50 self.assertFalse(res.empty) 

51 

52 def test_select_comment(self): 

53 query = ( 

54 "SELECT * FROM comments where block_id = '169fa742a8374fe9a516caecfb33432a'" 

55 ) 

56 ast = parse_sql(query) 

57 res = self.comments_table.select(ast) 

58 self.assertFalse(res.empty) 

59 

60 

61if __name__ == "__main__": 

62 unittest.main()