google-api-python-client
google-api-python-client copied to clipboard
Unable to use HttpMock
Environment details
- OS type and version:
macOS Monterey (v12.5.1) - Python version:
Python 3.8.13 - pip version:
pip 22.0.4 google-api-python-clientversion:google-api-python-client==1.12.11
Steps to reproduce
- ?
- ?
Code example
def test_service():
http = HttpMock('tests/include/gmail/resources/mock-email-ids.json', {'status': '200'})
service = build('gmail', 'v1', http=http)
response = service.users().messages().list(userId='me').execute()
where tests/include/gmail/resources/mock-email-ids.json is:
{
"messages":[
{
"id":"12345",
"threadId":"12345"
},
{
"id":"6789",
"threadId":"6789"
}
],
"resultSizeEstimate":2
}
Stack trace
ERROR googleapiclient.discovery:discovery.py:485 You are using HttpMock or HttpMockSequence withouthaving the service discovery doc in cache. Try calling build() without mocking once first to populate the cache.
I've even tried to run it without http argument (which in non-sense, what am I going to do if this is part of a CI/CD pipeline?), but still the same issue afterwards.
I'm having the same issue. I'm really new to googleapiclient, so I'm not sure if I'm just missing something in my understanding. I have something very similar to what you have (code for work, so I can't share), and that matches examples I've found in the docs and elsewhere.