Пример #1
0
    def test_post_merge_comments(self):
        source = Instagram.create_new(self.handler, actor={'username': '******'})

        # existing activity with one of the two comments in HTML_VIDEO_COMPLETE
        existing_activity = copy.deepcopy(HTML_VIDEO_ACTIVITY)
        existing_activity['object']['replies'] = {
            'totalItems': 1,
            'items': [COMMENT_OBJS[0]],
        }
        activity_key = Activity(
            id='tag:instagram.com,2013:789_456',
            activity_json=json_dumps(existing_activity)).put()

        # send HTML_VIDEO_COMPLETE to /post, check that the response and stored
        # activity have both of its comments
        resp = app.application.get_response(
            '/instagram/browser/post?token=towkin',
            method='POST',
            text=HTML_VIDEO_COMPLETE)

        self.assertEqual(200, resp.status_int, resp.text)
        self.assert_equals(HTML_VIDEO_ACTIVITY_FULL, resp.json)

        activity = activity_key.get()
        self.assert_equals(HTML_VIDEO_ACTIVITY_FULL,
                           json_loads(activity.activity_json))
Пример #2
0
 def test_poll(self):
     source = Instagram.create_new(self.handler,
                                   actor={'username': '******'})
     self.expect_task('poll',
                      eta_seconds=0,
                      source_key=source.key,
                      last_polled='1970-01-01-00-00-00')
     self.mox.ReplayAll()
     resp = app.application.get_response(
         '/instagram/browser/poll?username=snarfed', method='POST')
     self.assertEqual(200, resp.status_int, resp.text)
     self.assertEqual('OK', resp.json)
Пример #3
0
    def test_post(self):
        source = Instagram.create_new(self.handler, actor={'username': '******'})

        resp = app.application.get_response(
            '/instagram/browser/post?token=towkin',
            method='POST',
            text=HTML_VIDEO_COMPLETE)
        self.assertEqual(200, resp.status_int, resp.text)
        self.assertEqual(HTML_VIDEO_ACTIVITY_FULL, resp.json)

        activities = Activity.query().fetch()
        self.assertEqual(1, len(activities))
        self.assertEqual(source.key, activities[0].source)
        self.assertEqual(HTML_VIDEO_ACTIVITY_FULL,
                         json_loads(activities[0].activity_json))