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

Add test VersionHandler; Update Version Handler's API #130

Merged
merged 15 commits into from
Jul 2, 2019

Conversation

mpacer
Copy link
Member

@mpacer mpacer commented Jun 11, 2019

This refactors a bit of the data manipulation code in the handlers into individually testable utils.

This adds tests for the BookstoreVersionHandler.

There are a lot of issues that became obvious as I wrote these tests & helper utils. I will create separate issues for them, but I wanted to list them here.

  1. We should move BookstoreVersionHandler outside of the handlers.py module, into it's own module.
  2. We could simplify the code without much work. But, the response is being used for validation by front-ends (e.g., nteract_on_jupyter), and so we will need to make sure that this works for them as well.
    Specifically, this would involve removing the "bookstore": True bit in the response from the BookstoreVersionHandler
  3. Our tests are not all correctly awaiting the asynchronous handler methods, this means our synchronous code in those methods should be tested appropriately, but we'll need to add some more stuff to the other tests to get that working.

@todo
Copy link

todo bot commented Jun 11, 2019

Shuld we remove this; isn't it equivalent to the endpoint responding?

"bookstore": True, # TODO: Shuld we remove this; isn't it equivalent to the endpoint responding?
"version": self.settings['bookstore']["version"],
"validation": self.settings['bookstore']["validation"],
}


This comment was generated by todo based on a TODO comment in aa4e1e3 in #130. cc @mpacer.

@todo
Copy link

todo bot commented Jun 11, 2019

Should we remove this; isn't it equivalent to the endpoint responding?

"bookstore": True, # TODO: Should we remove this; isn't it equivalent to the endpoint responding?
"version": self.settings['bookstore']["version"],
"validation": self.settings['bookstore']["validation"],
}


This comment was generated by todo based on a TODO comment in e1d393b in #130. cc @mpacer.

@mpacer mpacer requested review from willingc and MSeal June 11, 2019 16:45
@codecov
Copy link

codecov bot commented Jun 11, 2019

Codecov Report

Merging #130 into master will increase coverage by 0.82%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master     #130      +/-   ##
==========================================
+ Coverage   47.32%   48.14%   +0.82%     
==========================================
  Files          11       11              
  Lines         374      378       +4     
==========================================
+ Hits          177      182       +5     
+ Misses        197      196       -1

@codecov
Copy link

codecov bot commented Jun 11, 2019

Codecov Report

Merging #130 into master will increase coverage by 0.43%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master     #130      +/-   ##
==========================================
+ Coverage   79.14%   79.57%   +0.43%     
==========================================
  Files          10       10              
  Lines         422      426       +4     
==========================================
+ Hits          334      339       +5     
+ Misses         88       87       -1

bookstore/handlers.py Outdated Show resolved Hide resolved
"""
get_handler = self.get_handler('/api/bookstore/')
setattr(get_handler, '_transforms', [])
get_handler.get()
Copy link
Member

@MSeal MSeal Jun 12, 2019

Choose a reason for hiding this comment

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

We don't assert anything. There's a lot of code issues that would appear to pass this test when they are in fact not doing what's intended

Copy link
Member Author

Choose a reason for hiding this comment

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

We're not doing this with all of the other handler tests. I agree it would be better, but I am not aiming at ideal right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

What are those code issues?

Copy link
Member

Choose a reason for hiding this comment

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

What if the get returns None? Or get_handler returns the post handler? This test as is doesn't confirm much.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the get should return None given the way that tornado handlers are defined (it treats the finish as a side-effect that I'm not sure how to hook into).

What it confirms is that the code runs without raising an error, meaning we've met the API for the get method, and that such a handler can be created without issue.

The problem is there is no way that I can seem to get access to whatever is sent over the wire based on get.

Copy link
Member

@willingc willingc left a comment

Choose a reason for hiding this comment

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

A couple of API design comments. It feels a bit squishy to have release version and validation together. Would it be preferable to have releases, features (validation seems more like something that has been done. From an api user standpoint, would it be more beneficial for me to know which features are possible, available, valid, and their settings?).

bookstore/handlers.py Outdated Show resolved Hide resolved
@todo
Copy link

todo bot commented Jun 27, 2019

Should we remove this; isn't it equivalent to the endpoint responding?

"bookstore": True, # TODO: Should we remove this; isn't it equivalent to the endpoint responding?
"version": self.settings['bookstore']["version"],
"validation": self.settings['bookstore']["validation"],
}


This comment was generated by todo based on a TODO comment in 1489aec in #130. cc @mpacer.

@mpacer mpacer force-pushed the testing branch 2 times, most recently from 84a6a23 to bfeecf1 Compare June 27, 2019 19:22
@mpacer
Copy link
Member Author

mpacer commented Jun 27, 2019

Hi @MSeal @willingc I made the changes to the API that you suggested as part of this PR now.

this has been rebased on master & is ready for the next round of reviews.

@mpacer mpacer changed the title Add tests for handlers; specifically VersionHandler Add test VersionHandler; Update Version Handler's API Jun 28, 2019
@mpacer mpacer requested a review from rgbkrk June 28, 2019 21:48
@mpacer mpacer added this to the 2.3 milestone Jun 28, 2019
This requires patching the handler's _transforms method to avoid raising 
an error when we run self.finish() on the handler code side.
This is likely an issue that we needed to deal with for other handlers 
but have not appropriately done. This is something we should revisit.
@mpacer
Copy link
Member Author

mpacer commented Jun 29, 2019

@willingc I'm sorry I missed your comment about changing the name of the top level property of the API response from "validation" to "features" — I just caught it and made the change

@willingc willingc merged commit 7d9a8a5 into nteract:master Jul 2, 2019
@willingc
Copy link
Member

willingc commented Jul 2, 2019

I don't see any outstanding issues in this PR so I am going to merge. Thanks @mpacer 🌻

@mpacer
Copy link
Member Author

mpacer commented Jul 2, 2019

Thanks!

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.

3 participants