hushh-labs / receiptor

MIT License
0 stars 0 forks source link

python tests with code coverage #2

Open jdonaldson opened 1 week ago

jdonaldson commented 1 week ago

It's a good idea to try and write some tests for your code here. Check out the pytest: https://docs.pytest.org/en/stable/, and its corresponding code coverage package : https://coverage.readthedocs.io/en/7.6.4/

It's not necessary to achieve 100% code coverage. Normally, 80% is considered good enough.

jdonaldson commented 1 week ago

You should also check out github actions : https://docs.github.com/en/actions

jdonaldson commented 1 week ago

Look into using mocks for Google's API : https://docs.python.org/3/library/unittest.mock.html

jdonaldson commented 1 week ago

I'd break things down into these steps:

  1. write a very simple test, get it to pass by running pytest in the working directory
  2. write a very simple github action that installs the receiptor package and runs pytest.
  3. write some more robust tests, and use the code coverage python package to calculate how much of the tests are covered. Use mocks for services that require authentication.
  4. try to get to 80% code coverage
  5. try to publish the package automatically if it passes all tests.
  6. try to automate the setting of the version number for the package, if tests pass.