Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

100 pct coverage #17

Merged
merged 12 commits into from
Oct 1, 2016
Merged

100 pct coverage #17

merged 12 commits into from
Oct 1, 2016

Conversation

markrwilliams
Copy link
Collaborator

Same as #16, but from a branch on this repo.

@codecov-io
Copy link

codecov-io commented Sep 28, 2016

Current coverage is 100% (diff: 100%)

Merging #17 into master will increase coverage by 41.75%

@@             master   #17   diff @@
=====================================
  Files             6    10     +4   
  Lines           364   936   +572   
  Methods           0     0          
  Messages          0     0          
  Branches         33    38     +5   
=====================================
+ Hits            212   936   +724   
+ Misses          149     0   -149   
+ Partials          3     0     -3   

Powered by Codecov. Last update f77d8ef...7580180

@markrwilliams
Copy link
Collaborator Author

@glyph @tomprince Review please!

Copy link
Owner

@tomprince tomprince left a comment

Choose a reason for hiding this comment

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

I've made a couple of comments regarding the API surface changes. I'll let you do with them what you will. On the other hand, there isn't currently any kind of API stability guarantee.

@@ -40,11 +40,14 @@ class GithubApi(object):
# - optional user/pass auth (token is not available with v3)
# - async API

def __init__(self, oauth2_token, baseURL=None):
def __init__(self, oauth2_token, baseURL=None, _reactor=None):
Copy link
Owner

Choose a reason for hiding this comment

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

Underscores don't make arguments private, since they can still be passed prepositionally. In any case, it is sensible to allow the reactor to be specified.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's true. It's a convention I picked up from what ends being a smaller part of Twisted than I remember - namely react.

I agree it seems OK to make the reactor part of the public API. But for other instances of _implementation_name=real_implementation, the other options I see are:

  1. use SynchronousTestCase.patch, which I don't like because of its global effect -- I don't want objects deeper in the call chain to pick up the mock.

  2. use a real implementation -- OK for opening files, crummier when it comes to, say, postGist or reactor

  3. make the real implementation a closure and the function that creates it take pluggable implementations. I did this for the run functions in the scripts because of react's API. *argv handly defeats my underscore convention, proving your point!

  4. works but adds a fair bit of indirection. I'm inclined to use 1) because of its convenience. What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

1 seems an expedient choice to get to 100% coverage, and things can be incrementally improved from there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tomprince Good deal. Thank you so much for the review and your general promptness!


def createToken(reactor, username, password, note, url, scopes,
_createToken=token.createToken,
_print=print):
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't seem like a good interface, particular considering that underscores don't make arguments private.
On the other hand, does it make sense for any of the script stuff to be part of the public API?

In any case, I think it might make sense to split this PR into two, one adding coverage for the API, and one for the script coverage.

@@ -9,7 +9,8 @@

def createToken(username, password,
note, note_url,
scopes, baseURL=None):
scopes, baseURL=None,
_getPage=client.getPage):
Copy link
Owner

Choose a reason for hiding this comment

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

Same comment here about underscores not making arguments private, and this is public API surface. In this case and below, I'm not sure that the added arguments are sensible as part of the api.

@markrwilliams
Copy link
Collaborator Author

@tomprince - the commit message fails to mention that reactor is now an argument of GithubApi's constructor. (It also has an incorrect possessive form).

I'm going to do a force push to fix it.

@tomprince's noted that explicit dependency injection expanded the
public API.  Use monkeypatching to work around that.

txgithub.api.GithubApi, however, still exposes "reactor" as an
argument to its initializer.

Some private names have been introduced to the scripts (_print for
print and _open for open) to ease monkeypatching.  Their absence from
__all__ should indicate they're private attributes of their modules.
@markrwilliams
Copy link
Collaborator Author

@tomprince Ready for another look. Thanks again!

@markrwilliams markrwilliams merged commit 4239b8a into master Oct 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants