-
Notifications
You must be signed in to change notification settings - Fork 649
chore: update attachment types to include selection support #223
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
SilentDemonSD
wants to merge
3
commits into
github:main
Choose a base branch
from
SilentDemonSD:schema-up
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.
+156
−10
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
135c4aa
chore: update attachment types to include selection support in typesc…
SilentDemonSD d6f311a
fix(nodejs/src/types.ts): allowed it to be omitted (displayName?: str…
SilentDemonSD 6a5dfc9
fix(python/copilot/types.py): keep displayName optional
SilentDemonSD 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,97 @@ | ||
| """ | ||
| Unit tests for generated session event types. | ||
|
|
||
| Tests for parsing session events and their data structures from the generated | ||
| session_events.py module. | ||
| """ | ||
|
|
||
|
|
||
| from copilot.generated.session_events import ( | ||
| Attachment, | ||
| AttachmentType, | ||
| SessionEventType, | ||
| ) | ||
|
|
||
|
|
||
| class TestSessionEventTypes: | ||
| """Test session event type enum values.""" | ||
|
|
||
| def test_session_start_event_type(self): | ||
| """The session.start event type should be recognized.""" | ||
| assert SessionEventType.SESSION_START.value == "session.start" | ||
|
|
||
| def test_session_snapshot_rewind_event_type(self): | ||
| """The session.snapshot_rewind event type should be recognized.""" | ||
| assert SessionEventType.SESSION_SNAPSHOT_REWIND.value == "session.snapshot_rewind" | ||
|
|
||
| def test_session_usage_info_event_type(self): | ||
| """The session.usage_info event type should be recognized.""" | ||
| assert SessionEventType.SESSION_USAGE_INFO.value == "session.usage_info" | ||
|
|
||
|
|
||
| class TestAttachmentTypes: | ||
| """Test attachment type parsing from generated session_events module.""" | ||
|
|
||
| def test_file_attachment_parsing(self): | ||
| """Test parsing a file attachment.""" | ||
| attachment_dict = { | ||
| "type": "file", | ||
| "path": "/path/to/file.py", | ||
| "displayName": "file.py", | ||
| } | ||
|
|
||
| attachment = Attachment.from_dict(attachment_dict) | ||
| assert attachment.type == AttachmentType.FILE | ||
| assert attachment.path == "/path/to/file.py" | ||
| assert attachment.display_name == "file.py" | ||
|
|
||
| def test_directory_attachment_parsing(self): | ||
| """Test parsing a directory attachment.""" | ||
| attachment_dict = { | ||
| "type": "directory", | ||
| "path": "/path/to/dir", | ||
| "displayName": "dir", | ||
| } | ||
|
|
||
| attachment = Attachment.from_dict(attachment_dict) | ||
| assert attachment.type == AttachmentType.DIRECTORY | ||
| assert attachment.path == "/path/to/dir" | ||
| assert attachment.display_name == "dir" | ||
|
|
||
| def test_selection_attachment_parsing(self): | ||
| """Test parsing a selection attachment with all fields.""" | ||
| attachment_dict = { | ||
| "type": "selection", | ||
| "filePath": "/path/to/file.py", | ||
| "displayName": "file.py:10-20", | ||
| "selection": { | ||
| "start": {"line": 10, "character": 0}, | ||
| "end": {"line": 20, "character": 50}, | ||
| }, | ||
| "text": "selected text content", | ||
| } | ||
|
|
||
| attachment = Attachment.from_dict(attachment_dict) | ||
| assert attachment.type == AttachmentType.SELECTION | ||
| assert attachment.file_path == "/path/to/file.py" | ||
| assert attachment.display_name == "file.py:10-20" | ||
| assert attachment.selection is not None | ||
| assert attachment.selection.start.line == 10 | ||
| assert attachment.selection.start.character == 0 | ||
| assert attachment.selection.end.line == 20 | ||
| assert attachment.selection.end.character == 50 | ||
| assert attachment.text == "selected text content" | ||
|
|
||
| def test_selection_attachment_minimal(self): | ||
| """Test parsing a selection attachment with only required fields.""" | ||
| attachment_dict = { | ||
| "type": "selection", | ||
| "filePath": "/path/to/file.py", | ||
| "displayName": "file.py", | ||
| } | ||
|
|
||
| attachment = Attachment.from_dict(attachment_dict) | ||
| assert attachment.type == AttachmentType.SELECTION | ||
| assert attachment.file_path == "/path/to/file.py" | ||
| assert attachment.selection is None | ||
| assert attachment.text is None |
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.
Uh oh!
There was an error while loading. Please reload this page.