MCPcopy Index your code
hub / github.com/InstaPy/InstaPy / BrowserMock

Class BrowserMock

tests/comment_util_tests.py:9–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class 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
28class CommentsUtilTests(unittest.TestCase):

Callers 1

Calls

no outgoing calls

Tested by 1