| 7 | |
| 8 | |
| 9 | class BrowserMock: |
| 10 | def __init__(self, caption=None, first_comment=None, comment_count=0): |
| 11 | self.caption = caption |
| 12 | self.first_comment = first_comment |
| 13 | self.comment_count = comment_count |
| 14 | |
| 15 | def execute_script(self, script, *kwargs): |
| 16 | if "edge_media_preview_comment.count" in script: |
| 17 | return self.comment_count |
| 18 | if ".graphql.shortcode_media.comments_disabled" in script: |
| 19 | return False |
| 20 | elif "edge_media_to_caption.edges[0]['node']['text']" in script: |
| 21 | return self.caption |
| 22 | elif "edge_media_to_parent_comment.edges[0]['node']['text']" in script: |
| 23 | return self.first_comment |
| 24 | else: |
| 25 | raise ValueError("Unexpected script") |
| 26 | |
| 27 | |
| 28 | class CommentsUtilTests(unittest.TestCase): |
no outgoing calls