Open CaptainDriftwood opened 1 year ago
Hi @Jasonca2,
currently we don't have any plans to implement box SDK mock available for testing. I'll bring this topic as an idea for an improvement to discuss during next team planning. In Python SDK test.unit
folder we have many mock fixtures and maybe some of them could be reused in your project.
Best,
@lukaszsocha2
I'd like to throw my support behind @Jasonca2 's request. I've just started my first project with boxsdk and would love to have an easier means to test my code that wraps the boxsdk with out having to mock everyhing I'm using in the SDK...which is something of a struggle, even with the examples in this repo's test folder.
Supposing I wrote a python script to perform this example task from the SDK Doc Site https://developer.box.com/guides/authentication/tokens/sdks/ -
from boxsdk import Client, OAuth2
oauth = OAuth2(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
access_token='ACCESS_TOKEN',
refresh_token='REFRESH_TOKEN',
)
client = Client(oauth)
user = client.user().get()
print(f'User ID is {user.id}')
To run pytest or mock assertions on this, with fake data for client_id
, client_secret
, etc. I'd have to mock the OAuth2, Client, and Client.user().get() objects, and set tghe value of the user's ID and make an assertion against the returned ID.
Is your feature request related to a problem? Please describe.
Will a library ever be implemented, similar to
Moto
for awsboto3
that developers can use to mock out the box-sdk for unit testing purposes?Describe the solution you'd like
The ability to create a fake box environment that the box sdk can interact with in Python. I'd like to be able to create metadata templates, folder structures, files with metadata attached, etc.
Describe alternatives you've considered
The only alternative is having to mock out each individual http request and response for the box sdk after recording them via a tool like
vcrpy