Revision: 356
Author: bslatkin
Date: Mon May 17 02:13:51 2010
Log: hub: accept pings on feeds which have no equivalence history yet
http://code.google.com/p/pubsubhubbub/source/detail?r=356

Modified:
 /trunk/hub/main.py
 /trunk/hub/main_test.py

=======================================
--- /trunk/hub/main.py  Mon May 17 01:57:39 2010
+++ /trunk/hub/main.py  Mon May 17 02:13:51 2010
@@ -1793,14 +1793,16 @@
       Dictionary mapping input topic URLs to their full set of aliases,
       including the input topic URL.
     """
-    topics = set(topics)
+    input_topics = set(topics)
     output_dict = {}
-    known_feeds = KnownFeed.get([KnownFeed.create_key(t) for t in topics])
+ known_feeds = KnownFeed.get([KnownFeed.create_key(t) for t in input_topics])

     topics = []
     feed_ids = []
-    for feed in known_feeds:
+    for topic, feed in zip(input_topics, known_feeds):
       if feed is None:
+        # For the case where the KnownFeed hasn't been written yet!
+        output_dict[topic] = set([topic])
         continue

       fix_feed_id = feed.feed_id
=======================================
--- /trunk/hub/main_test.py     Mon May 17 01:57:39 2010
+++ /trunk/hub/main_test.py     Mon May 17 02:13:51 2010
@@ -311,7 +311,7 @@
     KnownFeedIdentity.update(self.feed_id2, self.topic3)
     KnownFeedIdentity.update(self.feed_id2, self.topic4)

-    # topic5 -> KnownFeed missing; should not be expanded at all
+    # topic5 -> KnownFeed missing; default to simple mapping
     # topic6 -> KnownFeed where feed_id = None; default to simple mapping
     KnownFeed.create(self.topic6).put()

@@ -322,6 +322,7 @@
         self.topic2, self.topic3, self.topic4])

     expected = {
+      'http://example.com/woot5': set(['http://example.com/woot5']),
       'http://example.com/foobar1':
           set(['http://example.com/foobar1', 'http://example.com/meep2']),
       'http://example.com/meep2':
@@ -1184,15 +1185,6 @@
     inserted_topics = set(f.topic for f in FeedToFetch.all())
     self.assertEquals(expected_topics, inserted_topics)

-  def testIgnoreUnknownFeed(self):
-    self.handle('post',
-                ('hub.mode', 'PuBLisH'),
-                ('hub.url', self.topic),
-                ('hub.url', self.topic2),
-                ('hub.url', self.topic3))
-    self.assertEquals(204, self.response_code())
-    self.assertEquals([], list(FeedToFetch.all()))
-
   def testDuplicateUrls(self):
     db.put([KnownFeed.create(self.topic),
             KnownFeed.create(self.topic2)])

Reply via email to