espoem avatar

FPL: Updating tests & Minor fixes

espoem

Published: 20 Feb 2019 › Updated: 20 Feb 2019FPL: Updating tests & Minor fixes

FPL: Updating tests & Minor fixes


https://github.com/amosbastian/fpl

FPL is a Python wrapper for the FPL API created by amosbastian@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

Leave FPL: Updating tests & Minor fixes to:

Written by

Read more #fpl posts


Best Posts From espoem

We have not curated any of espoem's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From espoem