MasterMedo / typetest

:chart_with_upwards_trend: Improve your typing speed without leaving the terminal.
MIT License
24 stars 8 forks source link

test: test analyse functions #27

Closed nzdjb closed 3 years ago

nzdjb commented 3 years ago

Hello again!

Adding some unit tests for functions in analyse. Starting with making sure the external calls are mocked correctly and called the appropriate number of times. Planning to build out further into testing logic, though that may benefit from a refactor in a few places.

Creating as draft initially for discussion.

Please complete these tasks before opening your PR:

MasterMedo commented 3 years ago

First things first, thanks for engaging so much! :) I propose to add you as a collaborator to the repository, then we can commit to the same branches in the PR.

Now, the let's get down to business. Things that are currently on my mind:

  1. We need to create a test directory outside of the typetest directory.
  2. We need a poetry run test option that will run the tests.

Currently, I'm working on a well outlined CONTRIBUTING.md, I think that'll help new contributors. Especially those unfamiliar with poetry.

nzdjb commented 3 years ago

Sure, I'd be happy to be a collaborator, thanks. :-)

Great idea, I'll move the tests out and add the option.

nzdjb commented 3 years ago

Implemented very basic test for all the logic functions in analyse.

MasterMedo commented 3 years ago

Aham, this currently doesn't test anything, just sets a foundation how the test ought to be written?

The magic mock approach makes sense. In the long run I think it'd be best if we had some real mock results files for testing (multiple results.csvs and so on). So that pd.read_csv can actually read a csv. Regarding the plt.show function, we can ignore it as you did, but we can test the plt.plot function, or which ever is used, and check the arguments that it receives, those are the ones that will be plotted.

nzdjb commented 3 years ago

It does test a little bit:

They would catch a certain level of bugs e.g. a change causes an exception or the plot to not show at all.

So they're not very thorough or high value tests, but they are testing something. But you're right, the main value is in establishing the foundation.

MasterMedo commented 3 years ago

I agree on the testing purpose. It definitely isn't useless. I didn't mean to downplay your effort in any way. 😅

This is great, I am just trying to establish what needs to be built on top of it!