Пример #1
0
 def setUpClass(cls):
     # We're not testing auth here.
     SilkyConfig().SILKY_AUTHORISATION = False
     SilkyConfig().SILKY_AUTHENTICATION = False
     mock_suite = MockSuite()
     for _ in range(0, 100):
         mock_suite.mock_request()
Пример #2
0
 def setUpClass(cls):
     # We're not testing auth here.
     SilkyConfig().SILKY_AUTHORISATION = False
     SilkyConfig().SILKY_AUTHENTICATION = False
     mock_suite = MockSuite()
     for _ in range(0, 100):
         mock_suite.mock_request()
Пример #3
0
 def test_allowed_file_paths_nothing_specified(self):
     """by default we dont display any source, and it should return correctly"""
     request = MockSuite().mock_request()
     query = MockSuite().mock_sql_queries(request=request, n=1)[0]
     response = self.client.get(
         silky_reverse('request_sql_detail',
                       kwargs={
                           'sql_id': query.id,
                           'request_id': request.id
                       }))
     self.assertTrue(response.status_code == 200)
Пример #4
0
 def test_allowed_file_paths_unavailable_source(self):
     """if we request to view source that is not in the tracebackk we should get a 403"""
     request = MockSuite().mock_request()
     query = MockSuite().mock_sql_queries(request=request, n=1)[0]
     file_path = '/tmp/blah'
     with open(file_path, 'w') as f:
         f.write('test')
     response = self.client.get(silky_reverse('request_sql_detail',
                                              kwargs={
                                                  'sql_id': query.id,
                                                  'request_id': request.id
                                              }),
                                data={
                                    'line_num': 0,
                                    'file_path': file_path
                                })
     self.assertTrue(response.status_code == 403)
Пример #5
0
 def test_allowed_file_paths_available_source(self):
     """if we request to view source that exists in the TB all should be fine"""
     request = MockSuite().mock_request()
     query = MockSuite().mock_sql_queries(request=request, n=1)[0]
     tb = query.traceback_ln_only
     _, files = SQLDetailView()._urlify(tb)
     file_path = random.choice(files)
     with open(file_path, 'r') as f:
         line_num = random.randint(0, len(f.read().split('\n')))
     response = self.client.get(silky_reverse('request_sql_detail',
                                              kwargs={
                                                  'sql_id': query.id,
                                                  'request_id': request.id
                                              }),
                                data={
                                    'line_num': line_num,
                                    'file_path': file_path
                                })
     self.assertTrue(response.status_code == 200)
Пример #6
0
 def test_allowed_file_paths_unavailable_source(self):
     """if we request to view source that is not in the tracebackk we should get a 403"""
     request = MockSuite().mock_request()
     query = MockSuite().mock_sql_queries(request=request, n=1)[0]
     file_path = os.path.realpath(
         os.path.dirname(os.path.realpath(__file__)) +
         '/../../django_silky/settings.py')
     with open(file_path, 'r') as f:
         line_num = random.randint(0, len(f.read().split('\n')))
     response = self.client.get(silky_reverse('request_sql_detail',
                                              kwargs={
                                                  'sql_id': query.id,
                                                  'request_id': request.id
                                              }),
                                data={
                                    'line_num': line_num,
                                    'file_path': file_path
                                })
     self.assertTrue(response.status_code == 403)
Пример #7
0
from django.test import TestCase
from silk.tests import MockSuite
from silk.views.summary import SummaryView

mock_suite = MockSuite()


class TestSummaryView(TestCase):
    def test_longest_query_by_view(self):
        [mock_suite.mock_request() for _ in range(0, 10)]
        print([x.time_taken for x in SummaryView()._longest_query_by_view([])])
Пример #8
0
 def setUpClass(cls):
     mock_suite = MockSuite()
     for _ in range(0, 100):
         mock_suite.mock_request()
Пример #9
0
 def setUpClass(cls):
     mock_suite = MockSuite()
     for _ in range(0, 100):
         mock_suite.mock_request()