コード例 #1
0
 def test_tracker_url_encodes_search_term(self):
     search_term = "some string"
     tracker = Tracker()
     self.assertEquals(
         "https://www.googleapis.com/buzz/v1/activities/track?q=" + "some%20string",
         tracker._build_subscription_url(search_term),
     )
コード例 #2
0
  def test_tracker_rejects_empty_search_term(self):
    sender = '*****@*****.**'
    term = ''

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals(None, tracker.track(sender, term))
コード例 #3
0
 def test_tracker_builds_correct_pshb_url(self):
     search_term = "somestring"
     tracker = Tracker()
     self.assertEquals(
         "https://www.googleapis.com/buzz/v1/activities/track?q=%s" % search_term,
         tracker._build_subscription_url(search_term),
     )
コード例 #4
0
 def test_tracker_rejects_invalid_id_for_untracking(self):
     self._delete_all_subscriptions()
     sender = "[email protected]/Adium380DADCD"
     hub_subscriber = StubHubSubscriber()
     tracker = Tracker(hub_subscriber=hub_subscriber)
     subscription = tracker.untrack(sender, "1")
     self.assertEquals(None, subscription)
コード例 #5
0
  def test_tracker_rejects_empty_search_term(self):
    sender = '*****@*****.**'
    term = ''

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals(None, tracker.track(sender, term))
コード例 #6
0
  def _setup_subscription(self, sender='*****@*****.**',search_term='somestring'):
    search_term = search_term
    body = '%s %s' % (XmppHandler.TRACK_CMD,search_term)

    hub_subscriber = StubHubSubscriber()
    tracker = Tracker(hub_subscriber=hub_subscriber)
    subscription = tracker.track(sender, body)
    return subscription
コード例 #7
0
  def test_tracker_rejects_invalid_id_for_untracking(self):
    self._delete_all_subscriptions()
    sender = '[email protected]/Adium380DADCD'
    hub_subscriber = StubHubSubscriber()

    tracker = Tracker(hub_subscriber=hub_subscriber)

    subscription = tracker.untrack(sender, '1')
    self.assertEquals(None, subscription)
コード例 #8
0
    def _setup_subscription(self,
                            sender='*****@*****.**',
                            search_term='somestring'):
        search_term = search_term
        body = '%s %s' % (XmppHandler.TRACK_CMD, search_term)

        hub_subscriber = StubHubSubscriber()
        tracker = Tracker(hub_subscriber=hub_subscriber)
        subscription = tracker.track(sender, body)
        return subscription
コード例 #9
0
  def test_tracker_subscribes_with_urlencoded_callback_url(self):
    sender = '*****@*****.**'
    search_term='some string'
    hub_subscriber = StubHubSubscriber()

    tracker = Tracker(hub_subscriber=hub_subscriber)

    subscription = tracker.track(sender, search_term)
    expected_callback_url = '%s/posts?id=%s' % (settings.APP_URL, subscription.id())
    self.assertEquals(expected_callback_url, hub_subscriber.callback_url)
コード例 #10
0
  def test_tracker_subscribes_with_callback_url_that_identifies_subscriber_and_query_without_xmpp_client_identifier(self):
    sender = '[email protected]/Adium380DADCD'
    search_term='somestring'

    hub_subscriber = StubHubSubscriber()
    tracker = Tracker(hub_subscriber=hub_subscriber)

    subscription = tracker.track(sender, search_term)
    expected_callback_url = '%s/posts?id=%s' % (settings.APP_URL, subscription.id())
    self.assertEquals(expected_callback_url, hub_subscriber.callback_url)
コード例 #11
0
  def test_tracker_subscribes_with_urlencoded_callback_url(self):
    sender = '*****@*****.**'
    search_term='some string'
    hub_subscriber = StubHubSubscriber()

    tracker = Tracker(hub_subscriber=hub_subscriber)

    subscription = tracker.track(sender, search_term)
    expected_callback_url = '%s/posts?id=%s' % (settings.APP_URL, subscription.id())
    self.assertEquals(expected_callback_url, hub_subscriber.callback_url)
コード例 #12
0
  def test_tracker_subscribes_with_callback_url_that_identifies_subscriber_and_query_without_xmpp_client_identifier(self):
    sender = '[email protected]/Adium380DADCD'
    search_term='somestring'

    hub_subscriber = StubHubSubscriber()
    tracker = Tracker(hub_subscriber=hub_subscriber)

    subscription = tracker.track(sender, search_term)
    expected_callback_url = '%s/posts?id=%s' % (settings.APP_URL, subscription.id())
    self.assertEquals(expected_callback_url, hub_subscriber.callback_url)
コード例 #13
0
    def test_tracker_subscribes_with_callback_url_that_identifies_subscriber_and_query(self):
        sender = "*****@*****.**"
        search_term = "somestring"

        hub_subscriber = StubHubSubscriber()
        tracker = Tracker(hub_subscriber=hub_subscriber)
        subscription = tracker.track(sender, search_term)

        expected_callback_url = "http://%s.appspot.com/posts?id=%s" % (settings.APP_NAME, subscription.id())
        self.assertEquals(expected_callback_url, hub_subscriber.callback_url)
コード例 #14
0
    def test_tracker_saves_subscription(self):
        self._delete_all_subscriptions()

        self.assertEquals(0, len(Subscription.all().fetch(100)))
        sender = "*****@*****.**"
        search_term = "somestring"

        tracker = Tracker()
        subscription = tracker.track(sender, search_term)
        self.assertEquals(1, len(Subscription.all().fetch(100)))
        self.assertEquals(subscription, Subscription.all().fetch(1)[0])
コード例 #15
0
  def test_tracker_accepts_valid_string(self):
    sender = '*****@*****.**'
    search_term='somestring'
    tracker = Tracker(hub_subscriber=StubHubSubscriber())
    expected_callback_url = '%s/posts/%s/%s' % (settings.APP_URL, sender, search_term)
    expected_subscription = Subscription(url='https://www.googleapis.com/buzz/v1/activities/track?q=%s' % search_term, search_term=search_term, callback_url=expected_callback_url)

    actual_subscription = tracker.track(sender, search_term)

    self.assertEquals(expected_subscription.url, actual_subscription.url)
    self.assertEquals(expected_subscription.search_term, actual_subscription.search_term)
コード例 #16
0
  def test_tracker_accepts_valid_string(self):
    sender = '*****@*****.**'
    search_term='somestring'
    tracker = Tracker(hub_subscriber=StubHubSubscriber())
    expected_callback_url = '%s/posts/%s/%s' % (settings.APP_URL, sender, search_term)
    expected_subscription = Subscription(url='https://www.googleapis.com/buzz/v1/activities/track?q=%s' % search_term, search_term=search_term, callback_url=expected_callback_url)

    actual_subscription = tracker.track(sender, search_term)

    self.assertEquals(expected_subscription.url, actual_subscription.url)
    self.assertEquals(expected_subscription.search_term, actual_subscription.search_term)
コード例 #17
0
  def test_tracker_saves_subscription(self):
    self._delete_all_subscriptions()

    self.assertEquals(0, len(Subscription.all().fetch(100)))
    sender = '*****@*****.**'
    search_term='somestring'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    subscription = tracker.track(sender, search_term)
    self.assertEquals(1, len(Subscription.all().fetch(100)))
    self.assertEquals(subscription, Subscription.all().fetch(1)[0])
コード例 #18
0
  def test_tracker_untracks_valid_id(self):
    self._delete_all_subscriptions()
    sender = '[email protected]/Adium380DADCD'
    search_term='somestring'
    hub_subscriber = StubHubSubscriber()
    tracker = Tracker(hub_subscriber=hub_subscriber)
    track_subscription = tracker.track(sender, search_term)

    untrack_subscription = tracker.untrack(sender, track_subscription.id())

    self.assertEquals(track_subscription, untrack_subscription)
    self.assertFalse(Subscription.exists(track_subscription.id()))
    self.assertEquals('%s/posts?id=%s' % (settings.APP_URL, track_subscription.id()), hub_subscriber.callback_url)
コード例 #19
0
  def test_tracker_untracks_valid_id(self):
    self._delete_all_subscriptions()
    sender = '[email protected]/Adium380DADCD'
    search_term='somestring'
    hub_subscriber = StubHubSubscriber()
    tracker = Tracker(hub_subscriber=hub_subscriber)
    track_subscription = tracker.track(sender, search_term)

    untrack_subscription = tracker.untrack(sender, track_subscription.id())

    self.assertEquals(track_subscription, untrack_subscription)
    self.assertFalse(Subscription.exists(track_subscription.id()))
    self.assertEquals('%s/posts?id=%s' % (settings.APP_URL, track_subscription.id()), hub_subscriber.callback_url)
コード例 #20
0
 def test_tracker_accepts_valid_string(self):
     sender = "*****@*****.**"
     search_term = "somestring"
     hub_subscriber = StubHubSubscriber()
     tracker = Tracker(hub_subscriber=hub_subscriber)
     expected_callback_url = "http://%s.appspot.com/posts/%s/%s" % (settings.APP_NAME, sender, search_term)
     expected_subscription = Subscription(
         url="https://www.googleapis.com/buzz/v1/activities/track?q=%s" % search_term,
         search_term=search_term,
         callback_url=expected_callback_url,
     )
     actual_subscription = tracker.track(sender, search_term)
     self.assertEquals(expected_subscription.url, actual_subscription.url)
     self.assertEquals(expected_subscription.search_term, actual_subscription.search_term)
コード例 #21
0
    def test_tracker_untracks_valid_id(self):
        self._delete_all_subscriptions()

        sender = "[email protected]/Adium380DADCD"
        search_term = "somestring"

        hub_subscriber = StubHubSubscriber()
        tracker = Tracker(hub_subscriber=hub_subscriber)
        track_subscription = tracker.track(sender, search_term)
        untrack_subscription = tracker.untrack(sender, track_subscription.id())
        self.assertEquals(track_subscription, untrack_subscription)
        self.assertFalse(Subscription.exists(track_subscription.id()))
        self.assertEquals(
            "http://%s.appspot.com/posts?id=%s" % (settings.APP_NAME, track_subscription.id()),
            hub_subscriber.callback_url,
        )
コード例 #22
0
  def test_tracker_rejects_padded_empty_string(self):
    sender = '*****@*****.**'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals(None, tracker.track(sender, '   '))
コード例 #23
0
  def test_tracker_rejects_padded_empty_string(self):
    sender = '*****@*****.**'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals(None, tracker.track(sender, '   '))
コード例 #24
0
 def test_tracker_returns_none_given_invalid_integer(self):
   self.assertEquals(None, Tracker.extract_number('jaiku'))
   self.assertEquals(None, Tracker.extract_number(None))
コード例 #25
0
 def test_tracker_extracts_integer_id_given_string(self):
   self.assertEquals(7, Tracker.extract_number('7'))
コード例 #26
0
 def test_is_blank_works_on_nonblank_strings(self):
   self.assertFalse(Tracker.is_blank("  a"))
   self.assertFalse(Tracker.is_blank("adf    "))
   self.assertFalse(Tracker.is_blank("  adfas    "))
   self.assertFalse(Tracker.is_blank("daf-sa"))
コード例 #27
0
 def test_tracker_rejects_empty_search_term(self):
     sender = "*****@*****.**"
     term = ""
     tracker = Tracker()
     self.assertEquals(None, tracker.track(sender, term))
コード例 #28
0
 def test_is_blank_works_on_blank_strings(self):
   self.assertTrue(Tracker.is_blank(None))
   self.assertTrue(Tracker.is_blank(" "))
   self.assertTrue(Tracker.is_blank("    ")) # has a tab in it
   self.assertTrue(Tracker.is_blank(""))
コード例 #29
0
 def test_is_blank_works_on_nonblank_strings(self):
   self.assertFalse(Tracker.is_blank("  a"))
   self.assertFalse(Tracker.is_blank("adf    "))
   self.assertFalse(Tracker.is_blank("  adfas    "))
   self.assertFalse(Tracker.is_blank("daf-sa"))
コード例 #30
0
 def test_is_blank_works_on_blank_strings(self):
   self.assertTrue(Tracker.is_blank(None))
   self.assertTrue(Tracker.is_blank(" "))
   self.assertTrue(Tracker.is_blank("    ")) # has a tab in it
   self.assertTrue(Tracker.is_blank(""))
コード例 #31
0
  def test_tracker_builds_correct_pshb_url(self):
    search_term = 'somestring'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals('https://www.googleapis.com/buzz/v1/activities/track?q=%s' % search_term, tracker._build_subscription_url(search_term))
コード例 #32
0
  def test_tracker_url_encodes_search_term(self):
    search_term = 'some string'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals('https://www.googleapis.com/buzz/v1/activities/track?q=' + 'some%20string', tracker._build_subscription_url(search_term))
コード例 #33
0
  def test_tracker_builds_correct_pshb_url(self):
    search_term = 'somestring'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals('https://www.googleapis.com/buzz/v1/activities/track?q=%s' % search_term, tracker._build_subscription_url(search_term))
コード例 #34
0
 def test_tracker_returns_none_given_invalid_integer(self):
   self.assertEquals(None, Tracker.extract_number('jaiku'))
   self.assertEquals(None, Tracker.extract_number(None))
コード例 #35
0
 def test_tracker_rejects_padded_empty_string(self):
     sender = "*****@*****.**"
     tracker = Tracker()
     self.assertEquals(None, tracker.track(sender, "   "))
コード例 #36
0
  def test_tracker_url_encodes_search_term(self):
    search_term = 'some string'

    tracker = Tracker(hub_subscriber=StubHubSubscriber())

    self.assertEquals('https://www.googleapis.com/buzz/v1/activities/track?q=' + 'some%20string', tracker._build_subscription_url(search_term))
コード例 #37
0
 def test_tracker_extracts_integer_id_given_string(self):
   self.assertEquals(7, Tracker.extract_number('7'))