-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b57fb6f
commit 4373be0
Showing
9 changed files
with
66 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ lint: | |
shell: | ||
hatch shell | ||
|
||
ut: | ||
hatch run python -m unittest -v | ||
|
||
roles: | ||
@ python download-roles.py | ||
|
||
|
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
Empty file.
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,38 @@ | ||
from shgpt.utils.common import extract_code, prepare_prompt | ||
from shgpt.utils.conf import DEFAULT_IMAGE_DIR | ||
from os import path | ||
import unittest | ||
|
||
|
||
class ATestCommon(unittest.TestCase): | ||
def test_prepare_prompt(self): | ||
for args, expected in [ | ||
('hello', ('hello', [])), | ||
('hello @@test.png', ('hello', [path.join(DEFAULT_IMAGE_DIR, 'test.png')])), | ||
('hello /tmp/test.png', ('hello', ['/tmp/test.png'])), | ||
('hello/tmp/test.png', ('hello/tmp/test.png', [])), | ||
('hello@@test.png', ('hello@@test.png', [])), | ||
]: | ||
self.assertEqual(prepare_prompt(args), expected) | ||
|
||
def test_extract_code(self): | ||
for args, expected in [ | ||
('1+1', None), | ||
( | ||
""" | ||
``` | ||
1+1 | ||
``` | ||
""", | ||
'1+1', | ||
), | ||
( | ||
""" | ||
```python | ||
1+1 | ||
``` | ||
""", | ||
'1+1', | ||
), | ||
]: | ||
self.assertEqual(extract_code(args), expected) |