コード例 #1
0
ファイル: tests.py プロジェクト: zhoujh/jaikuengine
    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, 'explore/templates/recent.html')
コード例 #2
0
ファイル: tests.py プロジェクト: 2dpodcast/jaikuenginepatch
 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
ファイル: tests.py プロジェクト: AloneRoad/Inforlearn
  def test_public_frontpage(self):
    
    l = profile.label('front_get_public')
    r = self.client.get('/')
    l.stop()

    self.assertTemplateUsed(r, 'front/templates/front.html')
    self.assertWellformed(r)
コード例 #4
0
ファイル: tests.py プロジェクト: zhoujh/jaikuengine
    def test_public_frontpage(self):

        l = profile.label('front_get_public')
        r = self.client.get('/')
        l.stop()

        self.assertTemplateUsed(r, 'front/templates/front.html')
        self.assertWellformed(r)
コード例 #5
0
ファイル: tests.py プロジェクト: 2dpodcast/jaikuenginepatch
  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')
コード例 #6
0
ファイル: tests.py プロジェクト: zhoujh/jaikuengine
    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, 'explore/templates/recent.html')
コード例 #7
0
ファイル: tests.py プロジェクト: AloneRoad/Inforlearn
  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, 'actor/templates/overview.html')
    self.assertWellformed(r)
コード例 #8
0
ファイル: tests.py プロジェクト: zhoujh/jaikuengine
    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, 'actor/templates/overview.html')
        self.assertWellformed(r)
コード例 #9
0
ファイル: profile.py プロジェクト: CollabQ/CollabQ
    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)
コード例 #10
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)
コード例 #11
0
ファイル: tests.py プロジェクト: hfeeki/jaikuengine
 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)
コード例 #12
0
ファイル: tests.py プロジェクト: hfeeki/jaikuengine
 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)
コード例 #13
0
ファイル: queue.py プロジェクト: jimpick/jaikuengine
  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!
    api.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()
    self.assertEqual(task_ref.expire, None)
    
    # grabbin
    l = profile.label('api_task_get (unlocked)')
    task_ref = api.task_get(actor_ref, nick, action, uuid)
    l.stop()
    self.assertEqual(task_ref.expire, self.now + self.delta)
    
    # 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
    api.utcnow = lambda: new_now

    # grab again, EXPIRED
    task_ref = api.task_get(actor_ref, nick, action, uuid)
    self.assertEqual(task_ref.expire, new_now + self.delta)

    # 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)
コード例 #14
0
ファイル: tests.py プロジェクト: zhoujh/jaikuengine
 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)
コード例 #15
0
ファイル: tests.py プロジェクト: zhoujh/jaikuengine
 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)
コード例 #16
0
ファイル: queue.py プロジェクト: zhoujh/jaikuengine
    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)