costis94 / bookcut

Command Line Interface tool to download, organise and search free ebooks from your terminal in a moment.
MIT License
186 stars 11 forks source link

More efficient testing #14

Open DerPhysikeR opened 3 years ago

DerPhysikeR commented 3 years ago

Hi

In general, test cases should be independent of real server connections. They should run fast so that one can run them frequently during development. Also, they shouldn't spam webpages with requests, every time a developer runs the tests. If a test would require a server connection, use pytest.monkeypatch or something similar to mock it.

However, having a few connection dependent test cases, which run only once before deployment, is probably a good idea. But, for the previously mentioned reasons, they should be separated from the rest of the tests. I suggest using @pytest.mark.online or something similar.

Pytest marks allow you to skip specific tests if for example the option -m "not online" is passed. I would create a conftest.py file to make this behavior the default and only if a new custom --online option is passed to pytest, the tests marked with @pytest.mark.online are run.

I can send you a merge request for that if you want.

Also, don't use copyrighted material, like Hararis "Sapiens", in your test cases, that screams for legal trouble. On the contrary, I would love for bookcut to also support entirely legal book repositories like project gutenberg in the future, maybe even scientific publications from platforms like arxiv.

costis94 commented 3 years ago

Hi again!

All your suggestions and recommendations about testing sounding reasonable, but I have to spend some time studying the mentioned concepts and the good practices of testing. Please feel free to contribute.

Also, on this point, I want to thank you for your overall contribution and to note that your idea of ​​adding Project Gutenberg and other book repositories is superb and from now on a high priority. I will create a new issue about it.

DarrenPIngram commented 3 years ago

What is the correct way to upgrade (using the install link in the main page seems to point/download an old version). I am stuck on 1.3.3

costis94 commented 3 years ago

What is the correct way to upgrade (using the install link in the main page seems to point/download an old version). I am stuck on 1.3.3

I created a new issue.