-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1191 from jtoberling/main
Usability improvements
- Loading branch information
Showing
9 changed files
with
140 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,59 @@ | ||
import os | ||
|
||
from pathlib import Path | ||
from typing import List, Union | ||
|
||
from gpt_engineer.applications.cli.file_selector import FileSelector | ||
|
||
editorcalled = False | ||
|
||
|
||
def set_editor_called( | ||
self, input_path: Union[str, Path], init: bool = True | ||
) -> List[str]: | ||
global editorcalled | ||
editorcalled = True | ||
return [] | ||
|
||
|
||
def set_file_selector_tmpproject(tmp_path): | ||
project_path = tmp_path / "project/" | ||
os.mkdir(project_path) | ||
os.mkdir(project_path / "x") | ||
os.mkdir(project_path / "a") | ||
|
||
gpteng_path = project_path / ".gpteng" | ||
os.mkdir(gpteng_path) | ||
|
||
with open(gpteng_path / "file_selection.toml", "w") as file: | ||
file.write("[files]\n") | ||
file.write(' "x/xxtest.py" = "selected"\n') | ||
file.write(' "a/aatest.py" = "selected"\n') | ||
|
||
with open(project_path / "x/xxtest.py", "w") as file: | ||
file.write('print("Hello")') | ||
|
||
with open(project_path / "a/aatest.py", "w") as file: | ||
file.write('print("Hello")') | ||
|
||
return project_path | ||
|
||
|
||
def test_file_selector_enhancement_skip_file_selector(tmp_path): | ||
project_path = set_file_selector_tmpproject(tmp_path) | ||
fileSelector = FileSelector(project_path=project_path) | ||
fileSelector.editor_file_selector = set_editor_called | ||
fileSelector.ask_for_files(skip_file_selection=True) | ||
|
||
assert editorcalled is False, "FileSelector.skip_file_selector is not working" | ||
|
||
|
||
def test_file_selector_enhancement_sort(tmp_path): | ||
project_path = set_file_selector_tmpproject(tmp_path) | ||
fileSelector = FileSelector(project_path=project_path) | ||
|
||
sortedFiles = fileSelector.get_current_files(project_path) | ||
assert sortedFiles == [ | ||
"a/aatest.py", | ||
"x/xxtest.py", | ||
], "FileSelector.get_current_files is unsorted!" |