def test_time_spent_db_with_path(self): request = random.choice(self.requests) query_set = RequestsView()._get_objects(order_by="db_time", path=request.path) num_results = query_set.count() self.assertTrue(num_results) for result in query_set: self.assertEqual(result.path, request.path)
def test_time_spent_db_with_path(self): request = random.choice(self.requests) query_set = RequestsView()._get_objects(order_by='db_time', path=request.path) num_results = query_set.count() self.assertTrue(num_results) for result in query_set: self.assertEqual(result.path, request.path)
def test_ordering(self): self.assertSorted(objects=RequestsView()._get_objects(order_by='start_time'), sort_field='start_time') self.assertSorted(objects=RequestsView()._get_objects(order_by='path'), sort_field='path') self.assertSorted(objects=RequestsView()._get_objects(order_by='num_sql_queries'), sort_field='num_sql_queries') self.assertSorted(objects=RequestsView()._get_objects(order_by='time_taken'), sort_field='time_taken') self.assertSorted(objects=RequestsView()._get_objects(order_by='db_time'), sort_field='db_time')
def test_default(self): request = Mock(spec_set=['GET', 'session']) request.session = {} request.GET = {} context = RequestsView()._create_context(request) self.assertDictContainsSubset( { 'show': RequestsView.default_show, 'order_by': RequestsView.defualt_order_by, 'options_show': RequestsView.show, 'options_order_by': RequestsView.order_by, 'options_paths': RequestsView()._get_paths() }, context) self.assertNotIn('path', context) self.assertIn('results', context)
def test_get(self): request = Mock(spec_set=['GET', 'session']) request.session = {} show = 10 path = '/path/to/somewhere/' order_by = 'Path' request.GET = {'show': show, 'path': path, 'order_by': order_by} context = RequestsView()._create_context(request) self.assertDictContainsSubset( { 'show': show, 'order_by': order_by, 'path': path, 'options_show': RequestsView.show, 'options_order_by': RequestsView.order_by, 'options_paths': RequestsView()._get_paths() }, context) self.assertIn('results', context)
def test_default(self): request = Mock(spec_set=['GET', 'session']) request.session = {} request.GET = {} context = RequestsView()._create_context(request) self.assertTrue( dict_contains( { 'show': RequestsView.default_show, 'order_by': RequestsView.default_order_by, 'options_show': RequestsView.show, 'options_order_by': RequestsView().options_order_by, 'options_order_dir': RequestsView().options_order_dir, }, context)) self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths()) self.assertNotIn('path', context) self.assertIn('results', context)
def test_get(self): request = Mock(spec_set=['GET', 'session']) request.session = {} show = 10 path = '/path/to/somewhere/' order_by = 'path' request.GET = {'show': show, 'path': path, 'order_by': order_by} context = RequestsView()._create_context(request) self.assertTrue( dict_contains( { 'show': show, 'order_by': order_by, 'path': path, 'options_show': RequestsView.show, 'options_order_by': RequestsView().options_order_by, 'options_order_dir': RequestsView().options_order_dir, }, context)) self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths()) self.assertIn('results', context)
from django.conf.urls import patterns, url 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.requests import RequestsView from silk.views.sql import SQLView from silk.views.sql_detail import SQLDetailView from silk.views.summary import SummaryView, ClearView urlpatterns = patterns('silk.views', url(r'^$', SummaryView.as_view(), name='summary'), url(r'^clear/$', ClearView.as_view(), name='clear'), url(r'^requests/$', RequestsView.as_view(), name='requests'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/$', RequestView.as_view(), name='request_detail'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/sql/$', SQLView.as_view(), name='request_sql'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/sql/(?P<sql_id>[0-9]+)/$', SQLDetailView.as_view(), name='request_sql_detail'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/raw/$', Raw.as_view(), name='raw'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/profiling/$', ProfilingView.as_view(), name='request_profiling'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/profile/(?P<profile_id>[0-9]+)/$', ProfilingDetailView.as_view(), name='request_profile_detail'), url(r'^request/(?P<request_id>[a-zA-Z0-9\-]+)/profile/(?P<profile_id>[0-9]+)/sql/$', SQLView.as_view(), name='request_and_profile_sql'), url(r'^request/(?P<request_id>[a-zA-Z0-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'))
from django.conf.urls import patterns, url 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.requests import RequestsView from silk.views.sql import SQLView from silk.views.sql_detail import SQLDetailView from silk.views.summary import SummaryView urlpatterns = patterns( 'silk.views', url(r'^$', SummaryView.as_view(), name='summary'), url(r'^requests/$', RequestsView.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/$',
def test_path(self): request = random.choice(self.requests) objects = RequestsView()._get_objects(path=request.path) for r in objects: self.assertEqual(r.path, request.path)
def test_show(self): objects = RequestsView()._get_objects(show=10) self.assertEqual(len(objects), 10)
def test_defaults(self): objects = RequestsView()._get_objects() self.assertEqual(len(objects), 25) self.assertSorted(objects, 'start_time')
def test_path(self): requests = [MockSuite().mock_request() for _ in range(0, 3)] paths = RequestsView()._get_paths() for r in requests: self.assertIn(r.path, paths)
from silk.views.cprofile import CProfileView from silk.views.profile_detail import ProfilingDetailView from silk.views.profile_dot import ProfileDotView from silk.views.profile_download import ProfileDownloadView from silk.views.profiling import ProfilingView from silk.views.raw import Raw from silk.views.request_detail import RequestView from silk.views.requests import RequestsView from silk.views.sql import SQLView from silk.views.sql_detail import SQLDetailView from silk.views.summary import SummaryView app_name = 'silk' urlpatterns = [ path(route='', view=SummaryView.as_view(), name='summary'), path(route='requests/', view=RequestsView.as_view(), name='requests'), path( route='request/<uuid:request_id>/', view=RequestView.as_view(), name='request_detail', ), path( route='request/<uuid:request_id>/sql/', view=SQLView.as_view(), name='request_sql', ), path( route='request/<uuid:request_id>/sql/<int:sql_id>/', view=SQLDetailView.as_view(), name='request_sql_detail', ),