Esempio n. 1
0
  def test_task_post_process_any(self):
    """ test that api.post creates a task and additional calls resume
    """
    nick = '*****@*****.**'
    uuid = 'HOWNOW'
    message = 'BROWNCOW'

    actor_ref = api.actor_get(api.ROOT, nick)

    # DROP
    old_max = api.MAX_FOLLOWERS_PER_INBOX
    api.MAX_FOLLOWERS_PER_INBOX = 1

    try:
      entry_ref = api.post(actor_ref, nick=nick, uuid=uuid, message=message)
      self.assertEqual(entry_ref.extra['title'], message)
    
      # make sure we can repeat
      two_entry_ref = api.post(actor_ref, nick=nick, uuid=uuid, message=message)
      self.assertEqual(entry_ref.uuid, two_entry_ref.uuid)
    
      # and that task_process_any works
      # and run out the queue
      for i in range(5):
        api.task_process_any(api.ROOT, nick)
      
      self.assertRaises(exception.ApiNoTasks,
                        lambda: api.task_process_actor(api.ROOT, nick))
    finally:
      api.MAX_FOLLOWERS_PER_INBOX = old_max  
Esempio n. 2
0
  def test_task_post_process_any(self):
    """ test that api.post creates a task and additional calls resume
    """
    nick = '*****@*****.**'
    uuid = 'HOWNOW'
    message = 'BROWNCOW'

    actor_ref = api.actor_get(api.ROOT, nick)

    # DROP
    old_max = api.MAX_FOLLOWERS_PER_INBOX
    api.MAX_FOLLOWERS_PER_INBOX = 1

    entry_ref = api.post(actor_ref, nick=nick, uuid=uuid, message=message)
    self.assertEqual(entry_ref.extra['title'], message)
    
    # make sure we can repeat
    two_entry_ref = api.post(actor_ref, nick=nick, uuid=uuid, message=message)
    self.assertEqual(entry_ref.uuid, two_entry_ref.uuid)
    
    # and that task_process_actor works
    task_more = api.task_process_any(api.ROOT)
    self.assert_(task_more)

    # and run out the queue
    task_more = api.task_process_any(api.ROOT)
    self.assert_(task_more)
    task_more = api.task_process_any(api.ROOT)
    self.assert_(task_more)
    task_more = api.task_process_any(api.ROOT)
    self.assert_(task_more)
    task_more = api.task_process_any(api.ROOT)
    self.assert_(not task_more)

    def _nope():
      task_more = api.task_process_any(api.ROOT)
    
    self.assertRaises(exception.ApiNoTasks, _nope)

    api.MAX_FOLLOWERS_PER_INBOX = old_max  

    pass
Esempio n. 3
0
def api_vendor_queue_process(request):
  """ process a queue item, redirect to self if there were more """
  secret = request.REQUEST.get('secret')
  if secret != settings.QUEUE_VENDOR_SECRET:
    raise exception.ApiException(0x00, "Invalid secret")
  
  try:
    rv = api.task_process_any(api.ROOT)
    if rv:
      return http.HttpResponseRedirect(request.get_full_path())
  except exception.ApiNoTasks:
    pass
  return http.HttpResponse('')
Esempio n. 4
0
def api_vendor_queue_process(request):
    """ process a queue item, redirect to self if there were more """
    secret = request.REQUEST.get('secret')
    if secret != settings.QUEUE_VENDOR_SECRET:
        raise exception.ApiException(0x00, "Invalid secret")

    try:
        rv = api.task_process_any(api.ROOT)
        if rv:
            return http.HttpResponseRedirect(request.get_full_path())
    except exception.ApiNoTasks:
        pass
    return http.HttpResponse('')
Esempio n. 5
0
    def test_task_post_process_any(self):
        """ test that api.post creates a task and additional calls resume
    """
        nick = '*****@*****.**'
        uuid = 'HOWNOW'
        message = 'BROWNCOW'

        actor_ref = api.actor_get(api.ROOT, nick)

        # DROP
        old_max = api.MAX_FOLLOWERS_PER_INBOX
        api.MAX_FOLLOWERS_PER_INBOX = 1

        try:
            entry_ref = api.post(actor_ref,
                                 nick=nick,
                                 uuid=uuid,
                                 message=message)
            self.assertEqual(entry_ref.extra['title'], message)

            # make sure we can repeat
            two_entry_ref = api.post(actor_ref,
                                     nick=nick,
                                     uuid=uuid,
                                     message=message)
            self.assertEqual(entry_ref.uuid, two_entry_ref.uuid)

            # and that task_process_any works
            # and run out the queue
            for i in range(5):
                api.task_process_any(api.ROOT, nick)

            self.assertRaises(exception.ApiNoTasks,
                              lambda: api.task_process_actor(api.ROOT, nick))
        finally:
            api.MAX_FOLLOWERS_PER_INBOX = old_max
Esempio n. 6
0
def exhaust_queue_any():
  for i in xrange(1000):
    try:
      api.task_process_any(api.ROOT)
    except exception.ApiNoTasks:
      break
Esempio n. 7
0
 def _nope():
   task_more = api.task_process_any(api.ROOT)
Esempio n. 8
0
def exhaust_queue_any():
    for i in xrange(1000):
        try:
            api.task_process_any(api.ROOT)
        except exception.ApiNoTasks:
            break