Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ymir/tools/privileged/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async def _run(

if target_end is not None:
current_target_end = current_fields.get(TARGET_END_CUSTOM_FIELD)
if current_target_end is None or not current_target_end.get("value"):
if not current_target_end:
fields[TARGET_END_CUSTOM_FIELD] = target_end.strftime("%Y-%m-%d")

if not fields:
Expand Down
13 changes: 11 additions & 2 deletions ymir/tools/privileged/tests/unit/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ async def json():
),
(
{"target_end": datetime.date(2024, 12, 31)},
{"fields": {"customfield_10023": {"value": None}}},
{"fields": {"customfield_10023": None}},
{"customfield_10023": "2024-12-31"},
),
(
{"target_end": datetime.date(2024, 12, 31)},
{"fields": {"customfield_10023": "2024-11-01"}},
None,
),
(
{"fix_versions": ["rhel-1.2.3"], "severity": Severity.CRITICAL},
{"fields": {"fixVersions": [], "customfield_10840": {"value": None}}},
Expand Down Expand Up @@ -139,14 +144,18 @@ async def json():

@asynccontextmanager
async def put(url, json, headers):
assert expected_fields is not None, "PUT should not be called when no fields need updating"
assert url.endswith(f"rest/api/3/issue/{issue_key}")
assert json.get("fields") == expected_fields
yield flexmock(ok=True, raise_for_status=lambda: None)

flexmock(aiohttp.ClientSession).should_receive("get").replace_with(get)
flexmock(aiohttp.ClientSession).should_receive("put").replace_with(put)
Comment thread
antbob marked this conversation as resolved.
result = (await SetJiraFieldsTool().run(input={"issue_key": issue_key, **args})).result
assert result.startswith("Successfully")
if expected_fields is not None:
assert result.startswith("Successfully")
else:
assert result.startswith("No fields needed updating")


@pytest.mark.parametrize(
Expand Down
Loading