Fix object has no attribute error in Jira Notificator#958
Fix object has no attribute error in Jira Notificator#958tomasdavidorg wants to merge 1 commit intoopenshift:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WalkthroughThis pull request refactors email access in the Jira notificator by introducing a centralized Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
tests/test_jira_notificator.py (2)
75-81:⚠️ Potential issue | 🔴 CriticalTest expects old mention format, but production now uses
accountId.The production code changed to
[~accountId:{u.accountId}]format, but this test still expects[~tdavid](the.nameformat). The test mock also doesn't setaccountId. This test will fail.🐛 Fix test to match new format
def test_create_jira_comment_mentions(self): second_user = Mock() - second_user.name = "gjospin" + second_user.accountId = "account-id-2" self.assertEqual(self.ns.create_jira_comment_mentions([]), "") - self.assertEqual(self.ns.create_jira_comment_mentions([self.test_user]), "[~tdavid] ") - self.assertEqual(self.ns.create_jira_comment_mentions([self.test_user, second_user]), "[~tdavid] [~gjospin] ") + self.assertEqual(self.ns.create_jira_comment_mentions([self.test_user]), "[~accountId:test-account-id] ") + self.assertEqual(self.ns.create_jira_comment_mentions([self.test_user, second_user]), "[~accountId:test-account-id] [~accountId:account-id-2] ")Also add
accountIdto the test_user setup insetUp:self.test_user.name = "tdavid" self.test_user.displayName = "Tomas David" self.test_user.emailAddress = "tdavid@redhat.com" + self.test_user.accountId = "test-account-id"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_jira_notificator.py` around lines 75 - 81, The test test_create_jira_comment_mentions expects the old name-based mention format but production uses accountId; update the test to set accountId on the mocks (e.g., set self.test_user.accountId and second_user.accountId in setUp or within the test) and change the asserted strings to the new format produced by create_jira_comment_mentions (e.g., "[~accountId:{...}] " for each user) so the expectations match the current create_jira_comment_mentions output.
140-163:⚠️ Potential issue | 🔴 CriticalMultiple tests still expect the old
[~name]mention format.
test_create_assignee_notification_textand several other tests expect strings like[~tdavid] [~gjospin], but production now outputs[~accountId:...]. These mocks needaccountIdattributes and assertions need updating to match the new format.Affected tests:
test_create_assignee_notification_text,test_notify_assignees,test_create_qa_notification_text,test_notify_qa_contact,test_create_team_lead_notification_text,test_notify_team_lead,test_create_manager_notification_text,test_notify_manager,test_check_issue_and_notify_responsible_people.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_jira_notificator.py` around lines 140 - 163, The tests (e.g., test_create_assignee_notification_text) still expect the old Jira mention format "[~name]" while the production code now emits "[~accountId:...]", so update the mocks and assertions: add an accountId attribute to the mock assignee/QA/team lead/manager objects used in tests and change expected strings in assertions to the new "[~accountId:...]" format (or build expected mentions dynamically from the mock.accountId values) for the tested functions create_assignee_notification_text, create_qa_notification_text, create_team_lead_notification_text, create_manager_notification_text and the notification tests notify_assignees, notify_qa_contact, notify_team_lead, notify_manager, test_check_issue_and_notify_responsible_people.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tests/test_jira_notificator.py`:
- Around line 75-81: The test test_create_jira_comment_mentions expects the old
name-based mention format but production uses accountId; update the test to set
accountId on the mocks (e.g., set self.test_user.accountId and
second_user.accountId in setUp or within the test) and change the asserted
strings to the new format produced by create_jira_comment_mentions (e.g.,
"[~accountId:{...}] " for each user) so the expectations match the current
create_jira_comment_mentions output.
- Around line 140-163: The tests (e.g., test_create_assignee_notification_text)
still expect the old Jira mention format "[~name]" while the production code now
emits "[~accountId:...]", so update the mocks and assertions: add an accountId
attribute to the mock assignee/QA/team lead/manager objects used in tests and
change expected strings in assertions to the new "[~accountId:...]" format (or
build expected mentions dynamically from the mock.accountId values) for the
tested functions create_assignee_notification_text, create_qa_notification_text,
create_team_lead_notification_text, create_manager_notification_text and the
notification tests notify_assignees, notify_qa_contact, notify_team_lead,
notify_manager, test_check_issue_and_notify_responsible_people.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a66225b0-2622-47eb-b8c7-ddae54d4cea4
📒 Files selected for processing (2)
oar/notificator/jira_notificator.pytests/test_jira_notificator.py
|
@tomasdavidorg: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
🤔 need to fix the test cases. I will take a look tomorrow. |
https://redhat.atlassian.net/browse/OCPERT-340