Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
Former Member
4 years ago[25] Testing ?
I was wondering how you would recommend testing our scripts that make use of the CLI ?
There is for instance the --dry-run option, but do you use other means on your side ?
For instance, wou...
Former Member
4 years agoTo be honest, I have not used --dry-run
so much. I am playing around with test vault / items as you do, in order to check both the general behaviour and specific cases.
I have now reached a point where I am writing unittests for my code and I was looking for mocking the op
part. Firstofall because I am not really interested into testing the op
inside (that's for you folks ;) ) and more important because I do not want the test to require my input to authenticate.
Ideally, I would have something similar as requests-mock
which is available for the popular python lib requests
. You write code such as the following:
def my_test():
with requests_mock.Mocker() as mocker:
# mock the authentication request
mocker.post(
sender.authentication_url,
json={'access_token': 'test-token'},
status_code=200,
)
# mock a post request that will be performed by my code
mocker.post(sender.post_url, status_code=200)
# test my stuff
...