Skip to content

Commit

Permalink
[thermalctld] Refactor to allow for greater unit test coverage; Add m…
Browse files Browse the repository at this point in the history
…ore unit tests (sonic-net#157)

- Refactor thermalctld to reduce the amount of code in infinite loops, thus allowing us better unit test coverage
- Refactor mock_platform.py such that it inherits from sonic-platform-common in order to ensure it is aligned with the current API definitions (this introduces a test-time dependency on the sonic-platform-common package)
- Increase pytest verbosity to prevent truncation of error messages

- Miscellaneous cleanup:
    - Fixes to grammar
    - Remove unnecessary punctuation from log messages

- Increase overall unit test unit test coverage from 73% to 93%
  • Loading branch information
jleveque authored Mar 18, 2021
1 parent 70f4e7b commit 8509f43
Show file tree
Hide file tree
Showing 12 changed files with 1,189 additions and 542 deletions.
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ jobs:
set -xe
sudo pip2 install swsssdk-2.0.1-py2-none-any.whl
sudo pip2 install sonic_py_common-1.0-py2-none-any.whl
sudo pip2 install sonic_config_engine-1.0-py2-none-any.whl
sudo pip2 install sonic_platform_common-1.0-py2-none-any.whl
sudo pip3 install swsssdk-2.0.1-py3-none-any.whl
sudo pip3 install sonic_py_common-1.0-py3-none-any.whl
sudo pip3 install sonic_config_engine-1.0-py3-none-any.whl
sudo pip3 install sonic_platform_common-1.0-py3-none-any.whl
workingDirectory: $(Pipeline.Workspace)/target/python-wheels/
displayName: 'Install Python dependencies'
Expand Down
2 changes: 1 addition & 1 deletion sonic-thermalctld/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -v
addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -vv
326 changes: 180 additions & 146 deletions sonic-thermalctld/scripts/thermalctld

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion sonic-thermalctld/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
tests_require=[
'mock>=2.0.0; python_version < "3.3"',
'pytest',
'pytest-cov'
'pytest-cov',
'sonic-platform-common'
],
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
Loading

0 comments on commit 8509f43

Please sign in to comment.