Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests and new functional tests #65

Merged
merged 8 commits into from
Jan 18, 2022

Conversation

larsks
Copy link
Member

@larsks larsks commented Jan 11, 2022

This is the third in a series of pull requests (of which #62 is the first and #63 is the second).


This PR is all about tests:

  • It adds a new suite of functional tests that are in general more granular and provide better information in the event of failure.
  • It adds unit tests for all major modules. This PR does not include 100% test coverage, but should provide a model for how to write additional tests. I have intentionally skipped writing tests for the rolebinding methods because of function MocOpenShift::update_user_role_project needs refactoring #36.
  • It updates the CI workflow to run the unit tests for each pr.

@larsks larsks requested review from rob-baron and knikolla January 11, 2022 21:51
@larsks larsks force-pushed the feature/prepare-for-tests branch from 397e01c to a85eec2 Compare January 11, 2022 22:31
This introduces a new suite of functional tests. The tests are moved
into the `tests/functional` directory, which will allow us in
subsequent commits to place unit tests in `tests/unit`.
This adds a suite of unit tests for the flask application and modifies
the CI workflow to run unit tests in addition to the pre-commit
checks.
Several tests are marked with @pytest.mark.xfail() to indicate places
where the existing API may be problematic. For each of these tests, we
need to determine if the existing behavior is correct, and if it is,
modify the test so that it tests the current behavior and passes.
Add a GitHub workflow to run unit tests for each push and
pull-request.
- Add pytest-coverage to test-requirements.txt, which allows us to
  produce coverage reports.

- Update the CI workflow to include coverage reporting, which looks
  like this:

      Name                        Stmts   Miss  Cover
      -----------------------------------------------
      acct_mgt/__init__.py            0      0   100%
      acct_mgt/app.py               141     10    93%
      acct_mgt/defaults.py            2      0   100%
      acct_mgt/kubeclient.py         33     19    42%
      acct_mgt/moc_openshift.py     299    133    56%
      acct_mgt/wsgi.py                7      7     0%
      -----------------------------------------------
      TOTAL                         482    169    65%

- Add a note to the README about running unit tests.

x-branch: feature/tests
@larsks larsks force-pushed the feature/prepare-for-tests branch from a85eec2 to 4f94f88 Compare January 18, 2022 14:26
@rob-baron rob-baron merged commit d6e3516 into feature/prepare-for-tests Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants