FPL: Updating tests & Minor fixes

in #fpl5 years ago


https://github.com/amosbastian/fpl

FPL is a Python wrapper for the FPL API created by @amosbastian to extend the toolset for FPL fans. A new, open library gives an opportunity to develop new tools for players easily. It can be used for analytical tools or extensions to provide better overviews of teams and matches.

Although I haven't played FPL myself, I see that the project have a potential. Amos updated docs and added a disclaimer that contributions are welcome. So I wanted to try it myself. Unfortunately, there were a few hiccups, which made the first steps rather inconvenient.

One issue was that there were missing modules after installation with pip. I suppose it was a result of overlooking the version number; thus the code did not update in the PyPi repository. Another issue was that I couldn't run tests locally since they required credentials. Furthermore, when I started going through the code, I realised that some information is available to the player only, which means that two different people couldn't get the same result unless they had the same credentials. We all know that sharing credentials publicly is not a good idea.

For that reason, I decided to help a bit to update the tests so that they can be run locally without the credentials dependency. There is still some work to do, but I'd say the weak points were improved.

Tests

The primary goal of contributing to the FPL wrapper was to run the tests without issues. There was a basic test suite which covered most of the functionality. In most cases, it tested the expected outcome of successful cases.

Therefore, I added some more tests also to test the actual implementation and to abstract HTTP requests with mocks. The wanted result is clear, to have passing tests.

carbon 2min.png

Bug Fixes

When I was rewriting the tests, I found out that the logic of some functions had minor flaws that could return unwanted results. Moreover, the code contained some of a deprecated syntax.

image.png

In the example above, a logic flow was fixed. Before, the method returned the whole history if _transfers was set even though we wanted only history for a specific game week.

Code Reference

Sort:  
  • Great work, I'm really impressed with the testing techniques you have used. This is a great example post to get python examples of try, expect, raise & mocking.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @helo! Keep up the good work!

Thank you for fixing all the issues and adding all the additional tests, I really appreciate it!

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Hi @espoem!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @espoem!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Dear espoem:

We are SteemBet, the next generation STEEM based gaming platform. We are honored to invite you to join our first fantastic dice game, which is just the beginning of SteemBet game series. Our dividend system has now launched. The prize pool has already accumulated 2,000 STEEM and more than 60 players have participated in staking mining token SBT. A huge reward of 40,000 STEEM is awaiting! Join us NOW with other 500 STEEM users to loot HUGE dividend reward!!

SteemBet Team

Official Website
https://steem-bet.com

Discord Server
https://discord.gg/95cBN3W

Telegram Group
https://t.me/steembet