예제 #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  
예제 #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
예제 #3
0
파일: views.py 프로젝트: hfeeki/jaikuengine
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('')
예제 #4
0
파일: views.py 프로젝트: zhoujh/jaikuengine
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('')
예제 #5
0
파일: queue.py 프로젝트: zhoujh/jaikuengine
    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
예제 #6
0
파일: util.py 프로젝트: CollabQ/CollabQ
def exhaust_queue_any():
  for i in xrange(1000):
    try:
      api.task_process_any(api.ROOT)
    except exception.ApiNoTasks:
      break
예제 #7
0
 def _nope():
   task_more = api.task_process_any(api.ROOT)
예제 #8
0
def exhaust_queue_any():
    for i in xrange(1000):
        try:
            api.task_process_any(api.ROOT)
        except exception.ApiNoTasks:
            break