diff --git a/src/devranta/api.py b/src/devranta/api.py index 227f56e..3b314fc 100644 --- a/src/devranta/api.py +++ b/src/devranta/api.py @@ -15,6 +15,8 @@ class Api: self.token_Key = None self.session = None + + def patch_auth(self, request_dict=None): auth_dict = {"app": self.app_id} if self.auth: @@ -65,6 +67,11 @@ class Api: await self.session.close() 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): response = None if not await self.ensure_login(): diff --git a/src/devranta/tests.py b/src/devranta/tests.py index 123dcf6..8a8215e 100644 --- a/src/devranta/tests.py +++ b/src/devranta/tests.py @@ -17,6 +17,9 @@ class ApiTestCase(unittest.IsolatedAsyncioTestCase): async def test_get_user_id(self): 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): user_id = await self.api.get_user_id("retoor") self.assertTrue(await self.api.get_profile(user_id))