async def test_send_with_async_request(self):
     session = mock.Mock(post=asynctest.CoroutineMock(),
                         close=asynctest.CoroutineMock())
     async with AsyncHTTPRequest(session=session) as http:
         t = tracker.Tracker("UA-XXXXX-Y", http)
         await t.send("pageview", "/test")
         session.post.assert_called_once()
    def test_init_default(self, mocked_generate_uuid):
        mocked_generate_uuid.return_value = self.cid
        t = tracker.Tracker(self.account, self.mocked_http)

        assert t.account == self.account
        assert t.http == self.mocked_http
        assert t.hash_client_id is False
        assert t.params == {"v": 1, "tid": self.account, "cid": self.cid}
    def test_init(self):
        expected_user_id = 2
        t = tracker.Tracker(self.account,
                            self.mocked_http,
                            hash_client_id=True,
                            client_id=self.cid,
                            user_id=expected_user_id)

        assert t.account == self.account
        assert t.http == self.mocked_http
        assert t.hash_client_id is True
        assert t.params == {
            "v": 1,
            "tid": self.account,
            "cid": self.cid,
            "uid": expected_user_id
        }
 def setup_method(self, method):
     self.mocked_http = mock.Mock()
     self.account = "UA-XXXXX-Y"
     self.cid = str(uuid.uuid4())
     self.tracker = tracker.Tracker("UA-XXXXX-Y", self.mocked_http,
                                    self.cid)