Esempio n. 1
0
    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)
Esempio n. 2
0
 def tearDownClass(cls):
     obj = Analytics()
     obj.enableAnalytics()