Ejemplo n.º 1
0
 def test_ordering(self):
     self.assertSorted(objects=RootView()._get_objects(order_by='Recent'),
                       sort_field='start_time')
     self.assertSorted(objects=RootView()._get_objects(order_by='Path'),
                       sort_field='path')
     self.assertSorted(
         objects=RootView()._get_objects(order_by='Num. Queries'),
         sort_field='num_sql_queries')
     self.assertSorted(objects=RootView()._get_objects(order_by='Time'),
                       sort_field='time_taken')
     self.assertSorted(
         objects=RootView()._get_objects(order_by='Time on queries'),
         sort_field='db_time')
Ejemplo n.º 2
0
 def test_default(self):
     request = Mock(spec_set=['GET'])
     request.GET = {}
     context = RootView()._create_context(request)
     self.assertDictContainsSubset(
         {
             'show': RootView.default_show,
             'order_by': RootView.defualt_order_by,
             'options_show': RootView.show,
             'options_order_by': RootView.order_by,
             'options_paths': RootView()._get_paths()
         }, context)
     self.assertNotIn('path', context)
     self.assertIn('results', context)
Ejemplo n.º 3
0
 def test_time_spent_db_with_path(self):
     request = random.choice(self.requests)
     query_set = RootView()._get_objects(order_by='Time on queries',
                                         path=request.path)
     num_results = len(query_set)
     self.assertTrue(num_results)
     for result in query_set:
         self.assertEqual(result.path, request.path)
Ejemplo n.º 4
0
 def test_get(self):
     request = Mock(spec_set=['GET'])
     show = 10
     path = '/path/to/somewhere/'
     order_by = 'Path'
     request.GET = {'show': show, 'path': path, 'order_by': order_by}
     context = RootView()._create_context(request)
     self.assertDictContainsSubset(
         {
             'show': show,
             'order_by': order_by,
             'path': path,
             'options_show': RootView.show,
             'options_order_by': RootView.order_by,
             'options_paths': RootView()._get_paths()
         }, context)
     self.assertIn('results', context)
Ejemplo n.º 5
0
from django.conf.urls import patterns, url
from silk.views.documentation import DocumentationView

from silk.views.profile_detail import ProfilingDetailView
from silk.views.profiling import ProfilingView
from silk.views.raw import Raw
from silk.views.request_detail import RequestView
from silk.views.root import RootView
from silk.views.sql import SQLView
from silk.views.sql_detail import SQLDetailView

urlpatterns = patterns(
    'silk.views', url(r'^/$', RootView.as_view(), name='requests'),
    url(r'^/request/(?P<request_id>[0-9]*)/$',
        RequestView.as_view(),
        name='request_detail'),
    url(r'^/request/(?P<request_id>[0-9]*)/sql/$',
        SQLView.as_view(),
        name='request_sql'),
    url(r'^/request/(?P<request_id>[0-9]*)/sql/(?P<sql_id>[0-9]*)/$',
        SQLDetailView.as_view(),
        name='request_sql_detail'),
    url(r'^/request/(?P<request_id>[0-9]*)/raw/$', Raw.as_view(), name='raw'),
    url(r'^/request/(?P<request_id>[0-9]*)/profiling/$',
        ProfilingView.as_view(),
        name='request_profiling'),
    url(r'^/request/(?P<request_id>[0-9]*)/profile/(?P<profile_id>[0-9]*)/$',
        ProfilingDetailView.as_view(),
        name='request_profile_detail'),
    url(r'^/request/(?P<request_id>[0-9]*)/profile/(?P<profile_id>[0-9]*)/sql/$',
        SQLView.as_view(),
Ejemplo n.º 6
0
Archivo: urls.py Proyecto: rosscdh/silk
from django.conf.urls import patterns, url
from silk.views.documentation import DocumentationView

from silk.views.profile_detail import ProfilingDetailView
from silk.views.profiling import ProfilingView
from silk.views.raw import Raw
from silk.views.request_detail import RequestView
from silk.views.root import RootView
from silk.views.sql import SQLView
from silk.views.sql_detail import SQLDetailView


urlpatterns = patterns('silk.views',
                       url(r'^/$', RootView.as_view(), name='requests'),
                       url(r'^/request/(?P<request_id>[0-9]*)/$', RequestView.as_view(), name='request_detail'),
                       url(r'^/request/(?P<request_id>[0-9]*)/sql/$', SQLView.as_view(), name='request_sql'),
                       url(r'^/request/(?P<request_id>[0-9]*)/sql/(?P<sql_id>[0-9]*)/$', SQLDetailView.as_view(), name='request_sql_detail'),
                       url(r'^/request/(?P<request_id>[0-9]*)/raw/$', Raw.as_view(), name='raw'),
                       url(r'^/request/(?P<request_id>[0-9]*)/profiling/$', ProfilingView.as_view(), name='request_profiling'),
                       url(r'^/request/(?P<request_id>[0-9]*)/profile/(?P<profile_id>[0-9]*)/$', ProfilingDetailView.as_view(), name='request_profile_detail'),
                       url(r'^/request/(?P<request_id>[0-9]*)/profile/(?P<profile_id>[0-9]*)/sql/$', SQLView.as_view(), name='request_and_profile_sql'),
                       url(r'^/request/(?P<request_id>[0-9]*)/profile/(?P<profile_id>[0-9]*)/sql/(?P<sql_id>[0-9]*)/$', SQLDetailView.as_view(), name='request_and_profile_sql_detail'),
                       url(r'^/profile/(?P<profile_id>[0-9]*)/$', ProfilingDetailView.as_view(), name='profile_detail'),
                       url(r'^/profile/(?P<profile_id>[0-9]*)/sql/$', SQLView.as_view(), name='profile_sql'),
                       url(r'^/profile/(?P<profile_id>[0-9]*)/sql/(?P<sql_id>[0-9]*)/$', SQLDetailView.as_view(), name='profile_sql_detail'),
                       url(r'^/profiling/$', ProfilingView.as_view(), name='profiling'),
                       url(r'^/documentation/$', DocumentationView.as_view(), name='documentation'))

Ejemplo n.º 7
0
 def test_path(self):
     request = random.choice(self.requests)
     objects = RootView()._get_objects(path=request.path)
     for r in objects:
         self.assertEqual(r.path, request.path)
Ejemplo n.º 8
0
 def test_show(self):
     objects = RootView()._get_objects(show=10)
     self.assertEqual(len(objects), 10)
Ejemplo n.º 9
0
 def test_defaults(self):
     objects = RootView()._get_objects()
     self.assertEqual(len(objects), 25)
     self.assertSorted(objects, 'start_time')
Ejemplo n.º 10
0
 def test_path(self):
     requests = [MockSuite().mock_request() for _ in range(0, 3)]
     paths = RootView()._get_paths()
     for r in requests:
         self.assertIn(r.path, paths)
     self.assertIn('', paths)