Closed dbasunag closed 16 hours ago
Report bugs in Issues
The following are automatically added:
.pre-commit-config.yaml
exists in the repo.Available user actions:
/wip
to the PR, To remove it from the PR comment /wip cancel
to the PR./hold
, To un-block merging of PR comment /hold cancel
./verified
to the PR, to un-verify comment /verified cancel
to the PR.
verified label removed on each new commit push./cherry-pick <target branch to cherry-pick to>
in the PR.
/cherry-pick branch1 branch2
)/build-and-push-container
in the PR (tag will be the PR number).
/build-and-push-container --build-arg OPENSHIFT_PYTHON_WRAPPER_COMMIT=<commit_hash>
/<label name>
, to remove, use /<label name> cancel
/assign-reviewers
/check-can-merge
@coderabbitai review
The pull request introduces a suite of unit tests in the file tests/jira_utils/test_jira_utils.py
for the process_jira_command_line_config_file
, get_jira_information
, and get_jira_ids_from_file_content
functions from the apps.jira_utils.jira_information
module. It utilizes the pytest
framework along with pytest_mock
for mocking dependencies. The tests address scenarios involving empty and valid configurations, various input parameters for retrieving Jira information, and the extraction of Jira IDs from content. Additionally, a new configuration section for pyutils-jira
is added in tests/jira_utils/test_jira_cfg_file.yaml
. Changes to the pyproject.toml
file enhance coverage, type checking, and dependency management.
File | Change Summary |
---|---|
tests/jira_utils/test_jira_utils.py | Added unit tests for process_jira_command_line_config_file , get_jira_information , and get_jira_ids_from_file_content . Includes tests for empty and valid configurations, parameterized tests for various input scenarios, and extraction of Jira IDs. Uses pytest and pytest_mock . |
tests/jira_utils/test_jira_cfg_file.yaml | Introduced a new configuration section for pyutils-jira , including parameters for Jira integration such as url , token , resolved_statuses , issue_pattern , skip_project_ids , jira_target_versions , and version_string_not_targeted_jiras . |
pyproject.toml | Updated coverage threshold to 65, added stricter type-checking options in mypy , and configured ruff settings for line length and automatic fixing. |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
I think we should test per function, it will be simpler and better tests.
For example to test get_jira_ids_from_file_content
:
@pytest.mark.parametrize(
"content_and_expected",
[
pytest.param({"content": "pytest.mark.jira(ABC-1111)", "expected": {"ABC-1111"}}, id="pytest_mark_jira"),
pytest.param({"content": "JIRA ID is jira_id=ABC-1111", "expected": {"ABC-1111"}}, id="jira_id="),
pytest.param(
{"content": "JIRA URL is https://example.com/browse/ABC-1111", "expected": {"ABC-1111"}}, id="jira_url="
),
pytest.param(
{
"content": "pytest.mark.jira(ABC-1111)\nJIRA ID is jira_id=ABC-1112\nJIRA URL is https://example.com/browse/ABC-1113",
"expected": {"ABC-1111", "ABC-1112", "ABC-1113"},
},
id="multiple_jira",
),
pytest.param(
{
"content": "pytest.mark.jira(ABC-1111)\nJIRA ID is jira_id=ABC-1111\nJIRA URL is https://example.com/browse/ABC-1111",
"expected": {"ABC-1111"},
},
id="multiple_jira_same_ids",
),
pytest.param({"content": "No Jiera", "expected": set()}, id="no_jira"),
],
)
def test_get_jira_ids_from_file_content(content_and_expected):
jira_ids = get_jira_ids_from_file_content(
file_content=content_and_expected["content"], issue_pattern=r"([A-Z]+-[0-9]+)", jira_url="https://example.com"
)
assert jira_ids == content_and_expected["expected"]
and so on .....
@pytest.mark.parametrize( "content_and_expected", [ pytest.param({"content": "pytest.mark.jira(ABC-1111)", "expected": {"ABC-1111"}}, id="pytest_mark_jira"), pytest.param({"content": "JIRA ID is jira_id=ABC-1111", "expected": {"ABC-1111"}}, id="jira_id="), pytest.param( {"content": "JIRA URL is https://example.com/browse/ABC-1111", "expected": {"ABC-1111"}}, id="jira_url=" ), pytest.param( { "content": "pytest.mark.jira(ABC-1111)\nJIRA ID is jira_id=ABC-1112\nJIRA URL is https://example.com/browse/ABC-1113", "expected": {"ABC-1111", "ABC-1112", "ABC-1113"}, }, id="multiple_jira", ), pytest.param( { "content": "pytest.mark.jira(ABC-1111)\nJIRA ID is jira_id=ABC-1111\nJIRA URL is https://example.com/browse/ABC-1111", "expected": {"ABC-1111"}, }, id="multiple_jira_same_ids", ), pytest.param({"content": "No Jiera", "expected": set()}, id="no_jira"), ], ) def test_get_jira_ids_from_file_content(content_and_expected): jira_ids = get_jira_ids_from_file_content( file_content=content_and_expected["content"], issue_pattern=r"([A-Z]+-[0-9]+)", jira_url="https://example.com" ) assert jira_ids == content_and_expected["expected"]
Added suggested tests and updated name of the test based on your recommendation.
/verified
/verified
/verified
Summary by CodeRabbit
pyutils-jira
, specifying parameters for Jira integration, including URL, token, resolved statuses, and target versions.