Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Write Operations #2

Open
averagehat opened this issue Apr 21, 2015 · 3 comments
Open

Testing Write Operations #2

averagehat opened this issue Apr 21, 2015 · 3 comments

Comments

@averagehat
Copy link

test_samples.py shows how one can test read operations for this project. What would be a realistic way to test write operations (i.e. the right issues got created, the correct relations got created). I don't see a way to mock out the write operations.

I could create a test site that gets generated when we test.

@necrolyte2
Copy link
Member

python-redmine is built of of the request library so you just intercept the calls to post, put, delete

You can see how it is done at
https://github.com/VDBWRAIR/redsample/blob/master/redsample/test/test_samples.py#L68

self.patcher_get = mock.patch('requests.get', return_value=self.response)
self.mock_get = self.patcher_get.start()

Then self.mock_get is the request.get function mocked out and will intercept all get requests for you. Post, delete and put are also already in the setUp() function, but don't have a variable assigned to them.

@averagehat
Copy link
Author

Yes, I saw that. That's not quite I mean though.

For example, if I wanted to test make_issue_block_sample, I would want to be able to see that the relation was created afterwards.

@necrolyte2
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants