-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add Asana ticket detection to ticket compliance check #2430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Oxygen56
wants to merge
6
commits into
The-PR-Agent:main
Choose a base branch
from
Oxygen56:feat/asana-ticket-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+191
−3
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bafe543
fix: preserve original indentation character in /improve suggestions
Oxygen56 5a70b98
feat: add Asana ticket detection to ticket compliance check
Oxygen56 99b9f74
fix: align Asana ticket schema with Jinja template expectations
Oxygen56 3586598
fix: use exact dedent and preserve tab remainder in dedent_code
Oxygen56 2b76ed6
test: add unit tests for Asana ticket detection in ticket compliance …
Oxygen56 3ce5450
fix: address all bot review feedback for Asana ticket detection
Oxygen56 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| """ | ||
| Unit tests for Asana ticket detection in ticket_pr_compliance_check.py. | ||
|
|
||
| Tests cover: | ||
| - Full Asana URL detection | ||
| - Shorthand ASANA- prefix detection | ||
| - Edge cases (mixed content, no tickets, duplicates) | ||
| """ | ||
| from pr_agent.tools.ticket_pr_compliance_check import find_asana_tickets | ||
|
|
||
|
|
||
| class TestFindAsanaTickets: | ||
| """Tests for find_asana_tickets().""" | ||
|
|
||
| def test_detects_full_asana_url(self): | ||
| """Full Asana task URLs should be detected.""" | ||
| text = "See https://app.asana.com/0/123456/789012 for details" | ||
| tickets = find_asana_tickets(text) | ||
| assert "https://app.asana.com/0/123456/789012" in tickets | ||
|
|
||
| def test_detects_asana_shorthand(self): | ||
| """ASANA-123456789012 shorthand format should be detected.""" | ||
| text = "Task ASANA-123456789012 is complete" | ||
| tickets = find_asana_tickets(text) | ||
| assert any("123456789012" in t for t in tickets) | ||
|
|
||
| def test_detects_multiple_tickets(self): | ||
| """Multiple Asana references should all be found.""" | ||
| text = ( | ||
| "See ASANA-111111111111 and https://app.asana.com/0/22/333333333333" | ||
| ) | ||
| tickets = find_asana_tickets(text) | ||
| assert len(tickets) == 2 | ||
|
|
||
| def test_deduplicates_identical_tickets(self): | ||
| """Duplicate references to the same task should be deduplicated.""" | ||
| text = ( | ||
| "ASANA-123456789012 mentioned twice: ASANA-123456789012 again" | ||
| ) | ||
| tickets = find_asana_tickets(text) | ||
| assert len(tickets) == 1 | ||
|
|
||
| def test_returns_empty_for_no_tickets(self): | ||
| """Text without Asana references returns an empty list.""" | ||
| text = "No tickets here, just regular text" | ||
| tickets = find_asana_tickets(text) | ||
| assert tickets == [] | ||
|
|
||
| def test_returns_empty_for_empty_string(self): | ||
| """Empty string returns an empty list.""" | ||
| tickets = find_asana_tickets("") | ||
| assert tickets == [] | ||
|
|
||
| def test_ignores_github_urls(self): | ||
| """GitHub issue URLs should not be mistaken for Asana tickets.""" | ||
| text = "Fix https://github.com/owner/repo/issues/42" | ||
| tickets = find_asana_tickets(text) | ||
| assert tickets == [] | ||
|
|
||
| def test_shorthand_is_case_insensitive(self): | ||
| """Both ASANA- and asana- should be detected.""" | ||
| text = "asana-999999999999 lowercase works too" | ||
| tickets = find_asana_tickets(text) | ||
| assert len(tickets) == 1 | ||
| assert "999999999999" in tickets[0] | ||
|
|
||
| def test_shorthand_mixed_case_asana(self): | ||
| """Mixed-case shorthand like Asana-123... should also be detected.""" | ||
| text = "Asana-888888888888 mixed case" | ||
| tickets = find_asana_tickets(text) | ||
| assert len(tickets) == 1 | ||
| assert "888888888888" in tickets[0] | ||
|
|
||
| def test_shorthand_respects_word_boundary(self): | ||
| """Text preceding the shorthand must not be alphanumeric. | ||
| NOTASANA-123 (no delimiter before ASANA) should not match.""" | ||
| text = "Check NOTASANA-123456789012 in logs" | ||
| tickets = find_asana_tickets(text) | ||
| assert tickets == [] | ||
|
|
||
| def test_tickets_are_sorted(self): | ||
| """Returned list should be sorted alphabetically.""" | ||
| text = "ASANA-222222222222 ASANA-111111111111" | ||
| tickets = find_asana_tickets(text) | ||
| assert tickets == sorted(tickets) | ||
|
|
||
| def test_tickets_in_pr_description_mixed_content(self): | ||
| """Asana tickets mixed with other content in a PR description.""" | ||
| text = """## Summary | ||
| Fixes ASANA-123456789012 | ||
| Related to https://app.asana.com/0/99/888888888888 | ||
|
|
||
| Also see GitHub issue #42 | ||
| """ | ||
| tickets = find_asana_tickets(text) | ||
| assert len(tickets) == 2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to revert this as it's unrelated to the Asana detection, wdyt?