Exemplo n.º 1
0
 def test_elapsed(self):
     profile = ProfilingRecord()
     with self.assertRaises(AssertionError):
         profile.elapsed
     profile.start()
     self.assertIsNotNone(profile.elapsed)
     self.assertIsNone(profile.end_ts)
     self.assertIsNone(profile.duration)
Exemplo n.º 2
0
 def test_stop(self):
     profile = ProfilingRecord()
     self.assertRaises(AssertionError, profile.stop)
     profile.start().stop()
     self.assertIsNotNone(profile.start_ts)
     self.assertIsNotNone(profile.end_ts)
     self.assertIsNotNone(profile.duration)
     self.assertTrue(profile.duration > 0)
Exemplo n.º 3
0
 def test_elapsed(self):
     profile = ProfilingRecord()
     with self.assertRaises(AssertionError):
         profile.elapsed
     profile.start()
     self.assertIsNotNone(profile.elapsed)
     self.assertIsNone(profile.end_ts)
     self.assertIsNone(profile.duration)
Exemplo n.º 4
0
 def test_stop(self):
     profile = ProfilingRecord()
     self.assertRaises(AssertionError, profile.stop)
     profile.start().stop()
     self.assertIsNotNone(profile.start_ts)
     self.assertIsNotNone(profile.end_ts)
     self.assertIsNotNone(profile.duration)
     self.assertTrue(profile.duration > 0)
Exemplo n.º 5
0
 def test_start(self):
     profile = ProfilingRecord().start()
     self.assertIsNotNone(profile.start_ts)
     self.assertIsNone(profile.end_ts)
     self.assertIsNone(profile.duration)
     # now check again to see that end and duration are cleared
     profile.end_ts = datetime.datetime.utcnow()
     profile.duration = 1
     profile.start()
     self.assertIsNotNone(profile.start_ts)
     self.assertIsNone(profile.end_ts)
     self.assertIsNone(profile.duration)
Exemplo n.º 6
0
 def test_start(self):
     profile = ProfilingRecord().start()
     self.assertIsNotNone(profile.start_ts)
     self.assertIsNone(profile.end_ts)
     self.assertIsNone(profile.duration)
     # now check again to see that end and duration are cleared
     profile.end_ts = datetime.datetime.utcnow()
     profile.duration = 1
     profile.start()
     self.assertIsNotNone(profile.start_ts)
     self.assertIsNone(profile.end_ts)
     self.assertIsNone(profile.duration)
Exemplo n.º 7
0
    def test_capture(self):
        # repeat, but this time cancel before capture
        profile = ProfilingRecord()
        response = MockResponse(200)
        profile.start().set_response(response).capture()
        self.assertIsNotNone(profile.start_ts)
        self.assertIsNotNone(profile.end_ts)
        self.assertIsNotNone(profile.duration)
        self.assertIsNotNone(profile.id)
        self.assertEqual(response['X-Profiler-Duration'], profile.duration)

        profile = ProfilingRecord().cancel().capture()
        self.assertIsNone(profile.start_ts)
        self.assertIsNone(profile.end_ts)
        self.assertIsNone(profile.duration)
        self.assertIsNone(profile.id)
Exemplo n.º 8
0
    def test_capture(self):
        # repeat, but this time cancel before capture
        profile = ProfilingRecord()
        response = MockResponse(200)
        profile.start().set_response(response).capture()
        self.assertIsNotNone(profile.start_ts)
        self.assertIsNotNone(profile.end_ts)
        self.assertIsNotNone(profile.duration)
        self.assertIsNotNone(profile.id)
        self.assertEqual(response['X-Profiler-Duration'], profile.duration)

        profile = ProfilingRecord().cancel().capture()
        self.assertIsNone(profile.start_ts)
        self.assertIsNone(profile.end_ts)
        self.assertIsNone(profile.duration)
        self.assertIsNone(profile.id)