Пример #1
0
  def test_public_frontpage(self):
    
    l = profile.label('front_get_public')
    r = self.client.get('/')
    l.stop()

    self.assertTemplateUsed(r, 'front.html')
    self.assertWellformed(r)
Пример #2
0
    def test_explore_when_signed_out(self):

        l = profile.label("explore_get_public")
        r = self.client.get("/explore")
        l.stop()

        self.assertContains(r, "Latest Public Posts")
        self.assertTemplateUsed(r, "recent.html")
Пример #3
0
    def test_explore_when_signed_in(self):
        self.login("popular")

        l = profile.label("explore_get_logged_in")
        r = self.client.get("/explore")
        l.stop()

        self.assertContains(r, "Latest Public Posts")
        self.assertTemplateUsed(r, "recent.html")
Пример #4
0
  def test_public_frontpage_logged_in(self):
    self.login('popular')
    
    l = profile.label('front_get_logged_in')
    r = self.client.get('/')
    l.stop()

    r = self.assertRedirectsPrefix(r, '/user/popular/overview')
    self.assertTemplateUsed(r, 'overview.html')
    self.assertWellformed(r)
Пример #5
0
  def process_view(self, request, callback, callback_args, callback_kwargs):
    if not settings.DEBUG:
      return

    # hotshot data
    if '_prof_heavy' in request.REQUEST:
      self.profiler = profile.Profile()
      args = (request,) + callback_args
      return self.profiler.runcall(callback, *args, **callback_kwargs)

    # output data for use in the profiling code
    if ('_prof_db' in request.REQUEST 
        or request.META.get('HTTP_X_PROFILE', '') == 'db'):
        self.prof_label = common_profile.label(request.path)

    # output data to be included on the page
    if '_prof_quick' in request.REQUEST:
      try:
        common_profile.install_api_profiling()
      except:
        exception.log_exception()
        
      self.prof_label = common_profile.label(request.path)
Пример #6
0
 def test_popular_channel_logged_in(self):
   l = profile.label('channel_get_logged_in')
   r = self.login_and_get('popular', '/channel/popular')
   l.stop()
   self.assertContains(r, "Posts in #popular")
   self.assertWellformed(r)
Пример #7
0
 def test_popular_channel_public(self):
   l = profile.label('channel_get_public')
   r = self.login_and_get(None, '/channel/popular')
   l.stop()
   self.assertContains(r, "Posts in #popular")
   self.assertWellformed(r)
Пример #8
0
  def test_task_crud(self):
    # make a fake task for posting a simple message
    nick = '*****@*****.**'
    action = 'post'
    uuid = 'forever'
    message = 'more'
    
    actor_ref = api.actor_get(api.ROOT, nick)

    # STOP TIME! OMG!
    test_util.utcnow = lambda: self.now

    # makin
    l = profile.label('api_task_create')
    task_ref = api.task_create(actor_ref, 
                               nick, 
                               action, 
                               uuid,
                               args=[],
                               kw={'nick': nick,
                                   'message': message,
                                   'uuid': uuid
                                   }
                               )
    l.stop()
    
    # grabbin
    l = profile.label('api_task_get (unlocked)')
    task_ref = api.task_get(actor_ref, nick, action, uuid)
    l.stop()
    
    # grab again, LOCK VILLE
    def _again():
      task_ref = api.task_get(actor_ref, nick, action, uuid)
    
    
    l = profile.label('api_task_get (locked)')
    self.assertRaises(exception.ApiLocked, _again)
    l.stop()

    # increment time
    new_now = self.now + self.delta
    test_util.utcnow = lambda: new_now

    # grab again, EXPIRED
    task_ref = api.task_get(actor_ref, nick, action, uuid)

    # locked if we try again
    self.assertRaises(exception.ApiLocked, _again)

    # updatin
    l = profile.label('api_task_update')
    task_ref = api.task_update(actor_ref, nick, action, uuid, '1')
    l.stop()
    self.assertEqual(task_ref.progress, '1')
    
    # grab again, FRESH AND CLEAN
    task_ref = api.task_get(actor_ref, nick, action, uuid)
    self.assertEqual(task_ref.progress, '1')

    # removin
    l = profile.label('api_task_remove')
    api.task_remove(actor_ref, nick, action, uuid)
    l.stop()

    # grab again, NOT FOUND
    def _not_found():
      task_ref = api.task_get(actor_ref, nick, action, uuid)

    self.assertRaises(exception.ApiNotFound, _not_found)