Testing
Many tests have been scripted to allow for validating the functionality of this library.
Guidelines
All project code should have test cases built that cover the possible scenarios/values, and validate proper error handling. Generally speaking, each line of code should have “coverage” of a test case.
Unit Test
Python’s unit_test library is used for test cases against functions and classes. To run all tests, you can run the following command:
1python -m unittest discover tests/unit/
The output will be the number of tests executed and the successful count.
Code Coverage
A code coverage report is generated during each build to identify portions of code where a unit test case is not executed.
To execute this locally, run the following command:
1coverage run -m unittest discover tests/unit/
2coverage report -m
Reports
Code Climate
In addition to the above tests, a Code Climate report is run during the build process to validate against best practices.
The file .codeclimate.yml contains the modules for use and the configuration of values.
The following modules are enabled for scanning the code:
Bandit: Checks Python code for common security issues
EditorConfig: Checks files against
.editorconfigfile configurationFIXME: Checks for
TODO,FIXME,BUGcommentsPEP8: Formatting best practices
pylint: Linting and formatting of code
Sonar Python: Bugs, security, complexity, and other best practices