FPL: Updating tests & Minor fixes by espoem

View this thread on steempeak.com
· @espoem ·
$49.92
FPL: Updating tests & Minor fixes
<center><img src="https://files.steempeak.com/file/steempeak/espoem/Zx39Azk3-image.png" /><br/>https://github.com/amosbastian/fpl
</center>

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](https://files.steempeak.com/file/steempeak/espoem/rDlovsZ6-carbon202-min.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](https://files.steempeak.com/file/steempeak/espoem/5ej66hrs-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

- [PR #23](https://github.com/amosbastian/fpl/pull/23)
- [PR #25](https://github.com/amosbastian/fpl/pull/25)
- [PR #26](https://github.com/amosbastian/fpl/pull/26)
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 127 others
properties (23)
post_id70,400,774
authorespoem
permlinkfpl-updating-tests-and-minor-fixes
categoryfpl
json_metadata{"community":"steempeak","app":"steempeak\/1.7.2b","format":"markdown","tags":["fpl","python","development","utopian-io"],"users":["amosbastian"],"links":["https:\/\/github.com\/amosbastian\/fpl","\/@amosbastian","https:\/\/github.com\/amosbastian\/fpl\/pull\/23","https:\/\/github.com\/amosbastian\/fpl\/pull\/25","https:\/\/github.com\/amosbastian\/fpl\/pull\/26"],"image":["https:\/\/files.steempeak.com\/file\/steempeak\/espoem\/Zx39Azk3-image.png","https:\/\/files.steempeak.com\/file\/steempeak\/espoem\/rDlovsZ6-carbon202-min.png","https:\/\/files.steempeak.com\/file\/steempeak\/espoem\/5ej66hrs-image.png"]}
created2019-02-20 11:15:48
last_update2019-02-20 11:15:48
depth0
children7
net_rshares98,856,960,086,924
last_payout2019-02-27 11:15:48
cashout_time1969-12-31 23:59:59
total_payout_value37.678 SBD
curator_payout_value12.246 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,615
author_reputation59,186,440,518,630
root_title"FPL: Updating tests & Minor fixes"
beneficiaries
0.
accountutopian.pay
weight500
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (191)
@amosbastian ·
Thank you for fixing all the issues and adding all the additional tests, I really appreciate it!
πŸ‘  , ,
properties (23)
post_id70,401,357
authoramosbastian
permlinkre-espoem-fpl-updating-tests-and-minor-fixes-20190220t114126576z
categoryfpl
json_metadata{"tags":["fpl"],"app":"steemit\/0.1"}
created2019-02-20 11:41:27
last_update2019-02-20 11:41:27
depth1
children0
net_rshares24,666,437,080
last_payout2019-02-27 11:41:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length96
author_reputation174,225,255,912,876
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (3)
@partiko ·
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!
πŸ‘  
properties (23)
post_id70,402,779
authorpartiko
permlinkre-fpl-updating-tests-and-minor-fixes-20190220t123115
categoryfpl
json_metadata{"app":"partiko"}
created2019-02-20 12:31:18
last_update2019-02-20 12:31:18
depth1
children0
net_rshares560,166,085
last_payout2019-02-27 12:31:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length213
author_reputation39,204,266,552,701
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@helo ·
$10.95
- 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](https://join.utopian.io/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](https://review.utopian.io/result/3/2-2-1-1-1-1-4-).

---- 
Need help? Chat with us on [Discord](https://discord.gg/uTyJkNm).

[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , , , , , , , ,
properties (23)
post_id70,451,031
authorhelo
permlinkre-espoem-fpl-updating-tests-and-minor-fixes-20190221t151740097z
categoryfpl
json_metadata{"tags":["fpl"],"links":["https:\/\/join.utopian.io\/guidelines","https:\/\/review.utopian.io\/result\/3\/2-2-1-1-1-1-4-","https:\/\/discord.gg\/uTyJkNm","https:\/\/join.utopian.io\/"],"app":"steemit\/0.1"}
created2019-02-21 15:17:39
last_update2019-02-21 15:17:39
depth1
children1
net_rshares20,512,215,847,049
last_payout2019-02-28 15:17:39
cashout_time1969-12-31 23:59:59
total_payout_value8.316 SBD
curator_payout_value2.632 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length612
author_reputation119,612,833,307,875
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (19)
@utopian-io ·
Thank you for your review, @helo! Keep up the good work!
properties (22)
post_id70,539,659
authorutopian-io
permlinkre-re-espoem-fpl-updating-tests-and-minor-fixes-20190221t151740097z-20190223t183250z
categoryfpl
json_metadata{"app":"beem\/0.20.17"}
created2019-02-23 18:32:51
last_update2019-02-23 18:32:51
depth2
children0
net_rshares0
last_payout2019-03-02 18:32:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length56
author_reputation152,913,012,544,965
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-ua ·
#### 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](https://discord.gg/KpBNYGz)**
properties (22)
post_id70,455,075
authorsteem-ua
permlinkre-fpl-updating-tests-and-minor-fixes-20190221t170822z
categoryfpl
json_metadata{"app":"beem\/0.20.18"}
created2019-02-21 17:08:24
last_update2019-02-21 17:08:24
depth1
children0
net_rshares0
last_payout2019-02-28 17:08:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length285
author_reputation23,203,609,903,979
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@utopian-io ·
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](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

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

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
post_id70,578,076
authorutopian-io
permlinkre-fpl-updating-tests-and-minor-fixes-20190224t180820z
categoryfpl
json_metadata{"app":"beem\/0.20.17"}
created2019-02-24 18:08:21
last_update2019-02-24 18:08:21
depth1
children0
net_rshares0
last_payout2019-03-03 18:08:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length588
author_reputation152,913,012,544,965
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-bet ·
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
properties (22)
post_id71,891,050
authorsteem-bet
permlinksteem-bet-re-espoem-fpl-updating-tests-and-minor-fixes-20190323t050003141z
categoryfpl
json_metadata{"app":"partiko"}
created2019-03-23 05:00:03
last_update2019-03-23 05:00:03
depth1
children0
net_rshares0
last_payout2019-03-30 05:00:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length610
author_reputation18,478,497,974,222
root_title"FPL: Updating tests & Minor fixes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000