Example #1
0
 def test_handle_feed(self):
   item_a = {'permalinkUrl': 'A',
             'content': 'a http://a.com http://foo.com/self/link b'}
   superfeedr.handle_feed(json.dumps({'items': [item_a]}), self.source)
   self.assert_blogposts(
     [BlogPost(id='A', source=self.source.key, feed_item=item_a,
               unsent=['http://a.com/'])])  # self link should be discarded
Example #2
0
 def test_handle_feed(self):
   item_a = {'permalinkUrl': 'A',
             'content': 'a http://a.com http://foo.com/self/link b'}
   superfeedr.handle_feed(json.dumps({'items': [item_a]}), self.source)
   self.assert_blogposts(
     [BlogPost(id='A', source=self.source.key, feed_item=item_a,
               unsent=['http://a.com'])])  # self link should be discarded
Example #3
0
 def test_handle_feed_allows_bridgy_publish_links(self):
     item = {
         'permalinkUrl': 'A',
         'content': 'a https://brid.gy/publish/facebook b'
     }
     superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
     self.assert_equals(['https://brid.gy/publish/facebook'],
                        BlogPost.get_by_id('A').unsent)
Example #4
0
  def test_handle_feed_allows_bridgy_publish_links(self):
    item = {'permalinkUrl': 'A', 'content': 'a https://brid.gy/publish/twitter b'}
    self.expect_task('propagate-blogpost', key=BlogPost(id='A'))
    self.mox.ReplayAll()

    superfeedr.handle_feed({'items': [item]}, self.source)
    self.assert_equals(['https://brid.gy/publish/twitter'],
                       BlogPost.get_by_id('A').unsent)
Example #5
0
 def test_handle_feed_cleans_links(self):
   item = {
     'permalinkUrl': 'A',
     'id': 'A',
     'content': 'x <a href="http://abc?source=rss----12b80d28f892---4',
   }
   superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
   self.assert_blogposts([BlogPost(id='A', source=self.source.key,
                                   feed_item=item, unsent=['http://abc/'])])
Example #6
0
 def test_handle_feed_unwraps_t_umblr_com_links(self):
   item = {
     'permalinkUrl': 'A',
     'id': 'A',
     'content': 'x <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwrap%2Fped&amp;t=YmZkMzQy..."></a> y',
   }
   superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
   self.assert_blogposts([BlogPost(id='A', source=self.source.key,
                                   feed_item=item, unsent=['http://wrap/ped'])])
Example #7
0
  def test_preprocess_superfeedr_item(self):
    self.mox.StubOutWithMock(self.source, 'preprocess_superfeedr_item')

    def add_link(item):
      item['content'] += '\nhttp://added/by/preprocess'
    self.source.preprocess_superfeedr_item(self.item).WithSideEffects(add_link)

    self.mox.ReplayAll()
    superfeedr.handle_feed(self.feed, self.source)
    self.assertEquals(['http://added/by/preprocess'], BlogPost.query().get().unsent)
Example #8
0
 def test_handle_feed_cleans_links(self):
   item = {
     'permalinkUrl': 'A',
     'id': 'A',
     'content': 'x <a href="http://abc?source=rss----12b80d28f892---4',
   }
   superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
   posts = list(BlogPost.query())
   self.assert_blogposts([BlogPost(id='A', source=self.source.key,
                                   feed_item=item, unsent=['http://abc'])])
Example #9
0
 def test_handle_feed_unwraps_t_umblr_com_links(self):
   item = {
     'permalinkUrl': 'A',
     'id': 'A',
     'content': 'x <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwrap%2Fped&amp;t=YmZkMzQy..."></a> y',
   }
   superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
   posts = list(BlogPost.query())
   self.assert_blogposts([BlogPost(id='A', source=self.source.key,
                                   feed_item=item, unsent=['http://wrap/ped'])])
Example #10
0
  def test_handle_feed(self):
    item_a = {'permalinkUrl': 'A',
              'content': 'a http://a.com http://foo.com/self/link b'}
    post_a = BlogPost(id='A', source=self.source.key, feed_item=item_a,
                      # self link should be discarded
                      unsent=['http://a.com/'])
    self.expect_task('propagate-blogpost', key=post_a)
    self.mox.ReplayAll()

    superfeedr.handle_feed({'items': [item_a]}, self.source)
    self.assert_blogposts([post_a])
Example #11
0
  def test_handle_feed_truncates_links(self):
    self.mox.stubs.Set(superfeedr, 'MAX_BLOGPOST_LINKS', 2)

    item_a = {'permalinkUrl': 'A',
              'content': 'a http://a http://b http://c z'}
    post_a = BlogPost(id='A', source=self.source.key, feed_item=item_a,
                      unsent=['http://a/', 'http://b/'])
    self.expect_task('propagate-blogpost', key=post_a)
    self.mox.ReplayAll()

    superfeedr.handle_feed({'items': [item_a]}, self.source)
    self.assert_blogposts([post_a])
Example #12
0
  def test_handle_feed_cleans_links(self):
    item = {
      'permalinkUrl': 'A',
      'id': 'A',
      'content': 'x <a href="http://abc?source=rss----12b80d28f892---4',
    }
    post = BlogPost(id='A', source=self.source.key, feed_item=item,
                    unsent=['http://abc/'])
    self.expect_task('propagate-blogpost', key=post)
    self.mox.ReplayAll()

    superfeedr.handle_feed({'items': [item]}, self.source)
    self.assert_blogposts([post])
Example #13
0
  def test_handle_feed_unwraps_t_umblr_com_links(self):
    item = {
      'permalinkUrl': 'A',
      'id': 'A',
      'content': 'x <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwrap%2Fped&amp;t=YmZkMzQy..."></a> y',
    }
    post = BlogPost(id='A', source=self.source.key, feed_item=item,
                    unsent=['http://wrap/ped'])
    self.expect_task('propagate-blogpost', key=post)
    self.mox.ReplayAll()

    superfeedr.handle_feed({'items': [item]}, self.source)
    self.assert_blogposts([post])
Example #14
0
  def test_handle_feed(self):
    item_a = {'permalinkUrl': 'A',
              'content': 'a http://a.com http://foo.com/self/link b'}
    superfeedr.handle_feed(json.dumps({'items': [item_a]}), self.source)

    posts = list(BlogPost.query())
    self.assert_entities_equal(
      [BlogPost(id='A', source=self.source.key, feed_item=item_a,
                unsent=['http://a.com'])],  # self link should be discarded
      posts,
      ignore=('created', 'updated'))

    tasks = self.taskqueue_stub.GetTasks('propagate-blogpost')
    self.assertEqual(1, len(tasks))
    self.assert_equals(posts[0].key.urlsafe(),
                       testutil.get_task_params(tasks[0])['key'])
Example #15
0
    def test_handle_feed(self):
        item_a = {"permalinkUrl": "A", "content": "a http://a.com http://foo.com/self/link b"}
        superfeedr.handle_feed(json.dumps({"items": [item_a]}), self.source)

        posts = list(BlogPost.query())
        self.assert_entities_equal(
            [
                BlogPost(id="A", source=self.source.key, feed_item=item_a, unsent=["http://a.com"])
            ],  # self link should be discarded
            posts,
            ignore=("created", "updated"),
        )

        tasks = self.taskqueue_stub.GetTasks("propagate-blogpost")
        self.assertEqual(1, len(tasks))
        self.assert_equals(posts[0].key.urlsafe(), testutil.get_task_params(tasks[0])["key"])
Example #16
0
 def test_handle_feed_disabled_source(self):
     self.source.status = 'disabled'
     self.source.put()
     superfeedr.handle_feed(self.feed, self.source)
     self.assert_blogposts([])
Example #17
0
 def test_handle_feed_allows_bridgy_publish_links(self):
     item = {"permalinkUrl": "A", "content": "a https://brid.gy/publish/facebook b"}
     superfeedr.handle_feed(json.dumps({"items": [item]}), self.source)
     self.assert_equals(["https://brid.gy/publish/facebook"], BlogPost.get_by_id("A").unsent)
Example #18
0
 def test_handle_feed_no_items(self):
     superfeedr.handle_feed('{}', self.source)
     self.assert_blogposts([])
Example #19
0
 def test_handle_feed_source_missing_webmention_feature(self):
     self.source.features = ['listen']
     self.source.put()
     superfeedr.handle_feed(self.feed, self.source)
     self.assert_blogposts([])
Example #20
0
 def test_handle_feed_no_items(self):
   superfeedr.handle_feed('{}', self.source)
   self.assert_blogposts([])
Example #21
0
 def test_handle_feed_allows_bridgy_publish_links(self):
   item = {'permalinkUrl': 'A', 'content': 'a https://brid.gy/publish/facebook b'}
   superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
   self.assert_equals(['https://brid.gy/publish/facebook'],
                      BlogPost.get_by_id('A').unsent)
Example #22
0
 def test_handle_feed_source_missing_webmention_feature(self):
   self.source.features = ['listen']
   self.source.put()
   superfeedr.handle_feed(self.feed, self.source)
   self.assert_blogposts([])
Example #23
0
 def test_handle_feed_disabled_source(self):
   self.source.status = 'disabled'
   self.source.put()
   superfeedr.handle_feed(self.feed, self.source)
   self.assert_blogposts([])