Added get comments from user.
This commit is contained in:
		
							parent
							
								
									fd2c47da45
								
							
						
					
					
						commit
						00254503af
					
				| @ -15,6 +15,8 @@ class Api: | |||||||
|         self.token_Key = None |         self.token_Key = None | ||||||
|         self.session = None |         self.session = None | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     def patch_auth(self, request_dict=None): |     def patch_auth(self, request_dict=None): | ||||||
|         auth_dict = {"app": self.app_id} |         auth_dict = {"app": self.app_id} | ||||||
|         if self.auth: |         if self.auth: | ||||||
| @ -65,6 +67,11 @@ class Api: | |||||||
|         await self.session.close() |         await self.session.close() | ||||||
|         self.session = None |         self.session = None | ||||||
| 
 | 
 | ||||||
|  |     async def get_comments_from_user(self, username): | ||||||
|  |         user_id = await self.get_user_id(username) | ||||||
|  |         profile = await self.get_profile(user_id) | ||||||
|  |         return profile.get('content',{}).get('content',{}).get('comments',[]) | ||||||
|  | 
 | ||||||
|     async def post_comment(self, rant_id, comment): |     async def post_comment(self, rant_id, comment): | ||||||
|         response = None |         response = None | ||||||
|         if not await self.ensure_login(): |         if not await self.ensure_login(): | ||||||
|  | |||||||
| @ -17,6 +17,9 @@ class ApiTestCase(unittest.IsolatedAsyncioTestCase): | |||||||
|     async def test_get_user_id(self): |     async def test_get_user_id(self): | ||||||
|         self.assertTrue(await self.api.get_user_id("retoor")) |         self.assertTrue(await self.api.get_user_id("retoor")) | ||||||
| 
 | 
 | ||||||
|  |     async def test_get_comments_from_user(self): | ||||||
|  |         self.assertTrue(await self.api.get_comments_from_user("retoor")) | ||||||
|  | 
 | ||||||
|     async def test_get_profile(self): |     async def test_get_profile(self): | ||||||
|         user_id = await self.api.get_user_id("retoor") |         user_id = await self.api.get_user_id("retoor") | ||||||
|         self.assertTrue(await self.api.get_profile(user_id)) |         self.assertTrue(await self.api.get_profile(user_id)) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user