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

Add unit tests and new functional tests #66

Merged
merged 8 commits into from
Jan 18, 2022
Merged

Add unit tests and new functional tests #66

merged 8 commits into from
Jan 18, 2022

Conversation

larsks
Copy link
Member

@larsks larsks commented Jan 18, 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.

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 merged commit e23805d into master Jan 18, 2022
larsks added a commit that referenced this pull request Jan 18, 2022
Add unit tests and new functional tests

* Introduce new functional tests
* Add unit tests for flask app
* Add unit tests for moc_openshift quota functions
* Add unit tests for moc_openshift user functions
* Add unit tests for identity operations
* Add tests for acct_mgt.kubeclient
* Add unit test workflow
* Add support for coverage reporting
larsks added a commit that referenced this pull request Jan 18, 2022
* Introduce new functional tests
* Add unit tests for flask app
* Add unit tests for moc_openshift quota functions
* Add unit tests for moc_openshift user functions
* Add unit tests for identity operations
* Add tests for acct_mgt.kubeclient
* Add unit test workflow
* Add support for coverage reporting
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.

1 participant