Skip to content

Use MagicMock for unit testing WorkbenchConfig.py#697

Open
ysuarez wants to merge 2 commits into
mjordan:mainfrom
ysuarez:issue_445_with_mock
Open

Use MagicMock for unit testing WorkbenchConfig.py#697
ysuarez wants to merge 2 commits into
mjordan:mainfrom
ysuarez:issue_445_with_mock

Conversation

@ysuarez
Copy link
Copy Markdown
Contributor

@ysuarez ysuarez commented Oct 12, 2023

Link to Github issue or other discussion

#445

What does this PR do?

This is a simple refactor of the workbench config file unit tests to avoid using a redundant copy of code, and instead use a mock object.

What changes were made?

I replaced a redundant copy of the argparse logic used in the main workbench file with the use of unittest's MagicMock functionality. One reason is to reduce the risk of having a redundant copy of the argparse logic that may get out of sync in the future.

How to test / verify this PR?

Run this CLI command to test:
python3 tests/unit_tests_workbench_config.py -v

All tests should pass.

Interested Parties

@mjordan


Checklist

  • Before opening this PR, have you opened an issue explaining what you want to to do?
  • Have you run pycodestyle --show-source --show-pep8 --ignore=E402,W504 --max-line-length=200 yourfile.py?
  • Have you included some configuration and/or CSV files useful for testing this PR?
  • Have you written unit or integration tests if applicable?
  • Does the code added in this PR require a version of Python that is higher than the current minimum version?
  • If the changes in this PR require an additional Python library, have you included it in setup.py?
  • If the changes in this PR add a new configuration option, have you provided a default for when the option is not present in the .yml file?

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