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

Stop the iterator for empty responses and do not process ERROR responses #22

Merged
merged 7 commits into from Jun 21, 2018

Conversation

olitheolix
Copy link
Contributor

@olitheolix olitheolix commented Jun 20, 2018

This PR solves two problems I encountered:

  • Raise StopIteration for empty K8s responses (eg when the timeout expires).
  • Do not process K8s error responses but pass them verbatim to the user instead.

@codecov-io
Copy link

codecov-io commented Jun 20, 2018

Codecov Report

Merging #22 into master will increase coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
+ Coverage   92.53%   92.77%   +0.24%     
==========================================
  Files          14       14              
  Lines         898      914      +16     
==========================================
+ Hits          831      848      +17     
+ Misses         67       66       -1
Impacted Files Coverage Δ
kubernetes_asyncio/watch/watch.py 93.22% <100%> (+0.68%) ⬆️
kubernetes_asyncio/watch/watch_test.py 95.77% <100%> (+2.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb68f98...ce3f4f1. Read the comment docs.

@olitheolix olitheolix force-pushed the oli-k8s-errors branch 2 times, most recently from befcc02 to d956bc4 Compare June 20, 2018 10:53
@olitheolix
Copy link
Contributor Author

In case you accept this PR, can you please release a new version on PyPI?

Copy link
Owner

@tomplus tomplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

cnt = 0
async for _ in watch.stream(fake_api.get_namespaces):
cnt += 1
assert cnt == len(side_effects)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.assertEqual will be better here, it produces more meaningful errors.

}

ret = Watch().unmarshal_event(json.dumps(k8s_err), None)
assert ret['type'] == k8s_err['type']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using assertEqual...

@tomplus
Copy link
Owner

tomplus commented Jun 21, 2018

Latest release 1.0.0a4 has these changes, thanks again.

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

Successfully merging this pull request may close these issues.

None yet

3 participants