Esempio n. 1
0
    def test_save_if_have_body(self):

        obj = models.RequestSkill(path='/some/path/',
                                  method='get',
                                  body='some text')
        obj.save()
        self.assertEqual(obj.body, u'some text')
Esempio n. 2
0
    def test_save_if_have_end_time(self):

        date = datetime.datetime(2016, 1, 1, 12, 0, 3, tzinfo=pytz.UTC)
        obj = models.RequestSkill(path='/some/path/',
                                  method='get',
                                  end_time=date)
        obj.save()
        self.assertEqual(obj.end_time, date)
        self.assertEqual(obj.time_taken, 3000.0)
Esempio n. 3
0
    def test_greedy_garbage_collect(self):

        for x in range(3):
            obj = models.RequestSkill(path='/', method='get')
            obj.save()
        self.assertEqual(models.RequestSkill.objects.count(), 4)
        SilkyConfig().SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT = 50
        SilkyConfig().SILKY_MAX_RECORDED_REQUESTS = 3
        models.RequestSkill.garbage_collect(force=True)
        self.assertEqual(models.RequestSkill.objects.count(), 1)
Esempio n. 4
0
 def test_prof_file_default_storage(self):
     obj = models.RequestSkill(path='/some/path/', method='get')
     self.assertEqual(obj.prof_file.storage.__class__,
                      ProfilerResultStorage)
Esempio n. 5
0
    def test_save_if_have_no_end_time(self):

        obj = models.RequestSkill(path='/some/path/', method='get')
        self.assertEqual(obj.time_taken, None)
        obj.save()
        self.assertEqual(obj.time_taken, None)
Esempio n. 6
0
    def test_save_if_have_no_raw_body(self):

        obj = models.RequestSkill(path='/some/path/', method='get')
        self.assertEqual(obj.raw_body, '')
        obj.save()
        self.assertEqual(obj.raw_body, '')