def assertViewCount(self, request, response, count): now_dt = datetime.datetime.fromtimestamp(Services.time.time()) bgwork.clear() RequestSetupMiddleware().process_request(request) RequestSetupMiddleware().process_response(request, response) view_previous = Metrics.view.daily_count(now_dt) bgwork.perform() view_current = Metrics.view.daily_count(now_dt) self.assertEqual(view_current - view_previous, count)
def tearDown(self): # We disable performing the bgwork coz we do not want to send the email # notifiations just yet. bgwork.clear()