def testSendingAnalytics(self, mockSessionObj): session = mockSessionObj() response = MockResponse() response.appendResponse("test response") response.appendResponseCode(000) session.get.return_value = response self.assertEquals(0, session.get.call_count) self.assertEquals(0, session.get.call_count) obj = Analytics() obj.setSession(session) obj.disableAnalytics() t = obj.async_send_analytics(debug=False) t.join() self.assertEquals(0, session.get.call_count) obj.enableAnalytics() t = obj.async_send_analytics(debug=False) t.join() self.assertEquals(1, session.get.call_count) obj.enableAnalytics() t = obj.async_send_analytics(debug=True) t.join() self.assertEquals(2, session.get.call_count)
def tearDownClass(cls): obj = Analytics() obj.enableAnalytics()