aclark4life / vanity

Get package download statistics from PyPI
GNU General Public License v2.0
66 stars 14 forks source link

Add tests for by_two function and improve #50

Closed M3rs closed 7 years ago

M3rs commented 7 years ago

Add basic tests for by_two function: empty input, even and odd length input.

Refactor by_two function to return more explicit namedtuple with items (url, data).

M3rs commented 7 years ago

Pros/Cons of namedtuple:

(could probably rename it to something like release_info, based on use)

Code in count_downloads could look more like:

for release_info in get_release_info([package], json=json):
    for url in release_info.urls:
        # etc

Here is a talk by Raymond Hettinger (https://www.youtube.com/watch?v=wf-BqAjZb8M), towards the end he talks about how nametuples are great.

Pros:

Cons:

hugovk commented 7 years ago

Ha, I was just watching that video and had it paused! namedtuple bit is at here and makes sense.

Would you like to resolve the merge conflict?

M3rs commented 7 years ago

Resolved merge conflicts

hugovk commented 7 years ago

Thanks!