コード例 #1
0
 def test_invalid_subscriptions(self):
     retval = autodiscover.parse_file("this-file-does-not-exist.xml")
     self.assertEquals(retval, None)
     retval = autodiscover.parse_content(INVALID_CONTENT_1)
     self.assertEquals(retval, None)
     retval = autodiscover.parse_content(INVALID_CONTENT_2)
     self.assertEquals(retval, None)
コード例 #2
0
    def test_simple_nested(self):
        teststring = u"""\
<?xml version="1.0" encoding="utf-8"?>
<opml version="2.0"
 xmlns:miro="http://getmiro.com/opml/subscriptions">
  <head>
    <title>Sample OPML Flat Subscription List</title>
  </head>
  <body>
    <outline text="folder 1">
      <outline text="Sample Dummy RSS Feed 1" type="rss" xmlUrl="%s" />
      <outline text="folder1-1">
        <outline text="Sample Dummy Atom Feed 1" type="rss" xmlUrl="%s" />
      </outline>
    </outline>
    <outline text="folder 2">
      <outline text="folder2-1">
        <outline text="Sample Dummy RSS Feed 2" type="rss" xmlUrl="%s" />
      </outline>
      <outline text="Sample Dummy Atom Feed 2" type="rss" xmlUrl="%s" />
    </outline>
  </body>
</opml>
""" % (URL_1, URL_3, URL_2, URL_4)

        subscriptions = autodiscover.parse_content(teststring)
        self.assertEquals(len(subscriptions), 4)
        for feed_ in subscriptions:
            self.assertEquals(feed_['type'], 'feed')

        self.assertEquals(subscriptions[0]['url'], URL_1)
        self.assertEquals(subscriptions[1]['url'], URL_3)
        self.assertEquals(subscriptions[2]['url'], URL_2)
        self.assertEquals(subscriptions[3]['url'], URL_4)
コード例 #3
0
ファイル: opmltest.py プロジェクト: CodeforEvolution/miro
    def test_simple_nested(self):
        teststring = u"""\
<?xml version="1.0" encoding="utf-8"?>
<opml version="2.0"
 xmlns:miro="http://getmiro.com/opml/subscriptions">
  <head>
    <title>Sample OPML Flat Subscription List</title>
  </head>
  <body>
    <outline text="folder 1">
      <outline text="Sample Dummy RSS Feed 1" type="rss" xmlUrl="%s" />
      <outline text="folder1-1">
        <outline text="Sample Dummy Atom Feed 1" type="rss" xmlUrl="%s" />
      </outline>
    </outline>
    <outline text="folder 2">
      <outline text="folder2-1">
        <outline text="Sample Dummy RSS Feed 2" type="rss" xmlUrl="%s" />
      </outline>
      <outline text="Sample Dummy Atom Feed 2" type="rss" xmlUrl="%s" />
    </outline>
  </body>
</opml>
""" % (URL_1, URL_3, URL_2, URL_4)

        subscriptions = autodiscover.parse_content(teststring)
        self.assertEquals(len(subscriptions), 4)
        for feed_ in subscriptions:
            self.assertEquals(feed_['type'], 'feed')

        self.assertEquals(subscriptions[0]['url'], URL_1)
        self.assertEquals(subscriptions[1]['url'], URL_3)
        self.assertEquals(subscriptions[2]['url'], URL_2)
        self.assertEquals(subscriptions[3]['url'], URL_4)
コード例 #4
0
ファイル: subscriptiontest.py プロジェクト: cool-RR/Miro
 def test_reflexive_auto_discovery_in_atom(self):
     pageFile = file(REFLEXIVE_AUTO_DISCOVERY_PAGE_ATOM_FILENAME, "w")
     pageFile.write(REFLEXIVE_AUTO_DISCOVERY_PAGE_ATOM)
     pageFile.close()
     subscriptions = autodiscover.parse_content(REFLEXIVE_AUTO_DISCOVERY_IN_ATOM)
     try:
         self.assertDiscovered(subscriptions, SAMPLE_ATOM_SUBSCRIPTION_URL_1)
     finally:
         os.remove(REFLEXIVE_AUTO_DISCOVERY_PAGE_ATOM_FILENAME)
コード例 #5
0
 def test_reflexive_auto_discovery_in_rss(self):
     pageFile = file(REFLEXIVE_AUTO_DISCOVERY_PAGE_RSS_FILENAME, "w")
     pageFile.write(REFLEXIVE_AUTO_DISCOVERY_PAGE_RSS)
     pageFile.close()
     subscriptions = autodiscover.parse_content(
         REFLEXIVE_AUTO_DISCOVERY_IN_RSS)
     try:
         self.assertDiscovered(subscriptions, SAMPLE_RSS_SUBSCRIPTION_URL_1)
     finally:
         os.remove(REFLEXIVE_AUTO_DISCOVERY_PAGE_RSS_FILENAME)
コード例 #6
0
    def test_simple(self):
        feed1 = feed.Feed(u"http://example.com/feed/")
        feed1.finish_generate_feed(
            feed.RSSFeedImpl(u"http://example.com/feed/", feed1, u"Foo feed"))

        data = self._get_export([feed1], [])

        subs = autodiscover.parse_content(data)
        self.assertEquals(subs[0]["url"], u"http://example.com/feed/")
        self.assertEquals(subs[0]["title"], u"Foo feed")
        self.assertEquals(subs[0]["type"], "feed")
コード例 #7
0
ファイル: opmltest.py プロジェクト: CodeforEvolution/miro
    def test_simple(self):
        feed1 = feed.Feed(u"http://example.com/feed/")
        feed1.finish_generate_feed(
            feed.RSSFeedImpl(u"http://example.com/feed/",
                             feed1,
                             u"Foo feed"))
            
        data = self._get_export([feed1], [])

        subs = autodiscover.parse_content(data)
        self.assertEquals(subs[0]["url"], u"http://example.com/feed/")
        self.assertEquals(subs[0]["title"], u"Foo feed")
        self.assertEquals(subs[0]["type"], "feed")
コード例 #8
0
def _get_subs(entry):
    """Removes most of the boilerplate for getting subscriptions given
    some specific entry or entries in the <body> ... </body> section.
    """
    teststring = u"""\
<?xml version="1.0" encoding="utf-8" ?>
<!-- OPML generated by Miro v3.1-git on Thu Jul 22 15:23:10 2010 -->
<opml version="2.0"
 xmlns:miro="http://getmiro.com/opml/subscriptions">
<head>
  <title>miro_subscriptions.opml</title>
</head>
<body>
  %s
</body>
</opml>""" % entry

    return autodiscover.parse_content(teststring)
コード例 #9
0
ファイル: opmltest.py プロジェクト: CodeforEvolution/miro
def _get_subs(entry):
    """Removes most of the boilerplate for getting subscriptions given
    some specific entry or entries in the <body> ... </body> section.
    """
    teststring = u"""\
<?xml version="1.0" encoding="utf-8" ?>
<!-- OPML generated by Miro v3.1-git on Thu Jul 22 15:23:10 2010 -->
<opml version="2.0"
 xmlns:miro="http://getmiro.com/opml/subscriptions">
<head>
  <title>miro_subscriptions.opml</title>
</head>
<body>
  %s
</body>
</opml>""" % entry

    return autodiscover.parse_content(teststring)
コード例 #10
0
ファイル: commandline.py プロジェクト: zjmmjzzjm/miro
 def callback(info):
     if info.get('content-type') == expected_content_type:
         subscription_list = autodiscover.parse_content(info['body'])
         if subscription_list is None:
             text = _(
                 "This %(appname)s podcast file has an invalid format: "
                 "%(url)s.  Please notify the publisher of this file.", {
                     "appname": app.config.get(prefs.SHORT_APP_NAME),
                     "url": real_url
                 })
             _complain_about_subscription_url(text)
         else:
             subscription.Subscriber().add_subscriptions(subscription_list)
     else:
         text = _(
             "This %(appname)s podcast file has the wrong content type: "
             "%(url)s. Please notify the publisher of this file.", {
                 "appname": app.config.get(prefs.SHORT_APP_NAME),
                 "url": real_url
             })
         _complain_about_subscription_url(text)
コード例 #11
0
ファイル: commandline.py プロジェクト: bbucommander/miro
 def callback(info):
     if info.get('content-type') == expected_content_type:
         subscription_list = autodiscover.parse_content(info['body'])
         if subscription_list is None:
             text = _(
                 "This %(appname)s podcast file has an invalid format: "
                 "%(url)s.  Please notify the publisher of this file.",
                 {"appname": app.config.get(prefs.SHORT_APP_NAME),
                  "url": real_url}
                 )
             _complain_about_subscription_url(text)
         else:
             subscription.Subscriber().add_subscriptions(
                 subscription_list)
     else:
         text = _(
             "This %(appname)s podcast file has the wrong content type: "
             "%(url)s. Please notify the publisher of this file.",
             {"appname": app.config.get(prefs.SHORT_APP_NAME),
              "url": real_url}
             )
         _complain_about_subscription_url(text)
コード例 #12
0
 def test_atom_link_construct_in_atom(self):
     subscriptions = autodiscover.parse_content(ATOM_LINK_CONSTRUCT_IN_ATOM)
     self.assertDiscovered(subscriptions, SAMPLE_ATOM_SUBSCRIPTION_URL_1)
コード例 #13
0
 def test_parse_content_garbage(self):
     retval = autodiscover.parse_content("")
     self.assertEquals(retval, None)
     retval = autodiscover.parse_content(1)
     self.assertEquals(retval, None)