FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/tests/basic/test_scripting.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
13
(13)
Pull requests
8
(8)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
tests
/
basic
/
test_scripting.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (28 loc) · 1.32 KB
Breadcrumbs
cecli
/
tests
/
basic
/
test_scripting.py
Copy path
File metadata and controls
35 lines (28 loc) · 1.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from
pathlib
import
Path
from
unittest
.
mock
import
patch
from
cecli
.
coders
import
Coder
from
cecli
.
models
import
Model
from
cecli
.
utils
import
GitTemporaryDirectory
class
TestScriptingAPI
:
@
patch
(
"cecli.coders.base_coder.Coder.send"
)
async
def
test_basic_scripting
(
self
,
mock_send
):
with
GitTemporaryDirectory
():
# Setup - create an async generator mock
async
def
mock_send_side_effect
(
messages
,
functions
=
None
,
tools
=
None
):
# Simulate the async generator behavior
coder
.
partial_response_content
=
"Changes applied successfully."
coder
.
partial_response_function_call
=
None
yield
"Changes applied successfully."
mock_send
.
side_effect
=
mock_send_side_effect
# Test script
fname
=
Path
(
"greeting.py"
)
fname
.
touch
()
fnames
=
[
str
(
fname
)]
model
=
Model
(
"gpt-4-turbo"
)
coder
=
await
Coder
.
create
(
main_model
=
model
,
fnames
=
fnames
)
result1
=
await
coder
.
run
(
"make a script that prints hello world"
)
result2
=
await
coder
.
run
(
"make it say goodbye"
)
# Assertions
assert
mock_send
.
call_count
==
2
assert
result1
==
"Changes applied successfully."
assert
result2
==
"Changes applied successfully."
Back
|
FazBrowse Home
|
New Git URL