def test_do_kpi_with_tenant(self):
        fake_request = self.mox.CreateMockAnything()
        objects = self.mox.CreateMockAnything()
        models.RawData.objects.filter(tenant='55555').AndReturn(objects)
        objects.count().AndReturn(1)
        results = self.mox.CreateMockAnything()
        models.RequestTracker.objects.select_related().AndReturn(results)
        results.exclude(last_timing=None).AndReturn(results)
        results.exclude(start__lt=mox.IgnoreArg()).AndReturn(results)
        results.order_by('duration').AndReturn(results)
        tracker = self.mox.CreateMockAnything()
        tracker.last_timing = self.mox.CreateMockAnything()
        tracker.last_timing.end_raw = self.mox.CreateMockAnything()
        tracker.last_timing.end_raw.event = 'test.end'
        tracker.last_timing.end_raw.tenant = '55555'
        deployment = self.mox.CreateMockAnything()
        deployment.name = 'dep1'
        tracker.last_timing.end_raw.deployment = deployment
        tracker.lifecycle = self.mox.CreateMockAnything()
        tracker.lifecycle.instance = INSTANCE_ID_1
        tracker.duration = 10
        results.__iter__().AndReturn([tracker].__iter__())
        self.mox.ReplayAll()

        resp = stacky_server.do_kpi(fake_request, '55555')
        self.assertEqual(resp.status_code, 200)
        body = resp.content
        body = json.loads(body)
        self.assertEqual(len(body), 2)
        self.assertEqual(body[0], ["Event", "Time", "UUID", "Deployment"])
        time = stacky_server.sec_to_time(10) % u'%s'
        self.assertEqual(body[1], [u'test', time, INSTANCE_ID_1, u'dep1'])

        self.mox.VerifyAll()
dataset/ETHPy150Open openstack/stacktach/tests/unit/test_stacky_server.py/StackyServerTestCase.test_do_kpi_with_tenant/swapped operands of `%`