-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
c8898d0
commit 4f96011
Showing
2 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from codeinterpreterapi.chains import remove_download_link, get_file_modifications | ||
|
||
|
||
def test_remove_download_link() -> None: | ||
example = ( | ||
"I have created the plot to your dataset.\n\n" | ||
"Link to the file [here](sandbox:/plot.png)." | ||
) | ||
assert ( | ||
remove_download_link(example).formatted_response.strip() | ||
== "I have created the plot to your dataset." | ||
) | ||
|
||
|
||
def test_get_file_modifications() -> None: | ||
base_code = """ | ||
import matplotlib.pyplot as plt | ||
x = list(range(1, 11)) | ||
y = [29, 39, 23, 32, 4, 43, 43, 23, 43, 77] | ||
plt.plot(x, y, marker='o') | ||
plt.xlabel('Index') | ||
plt.ylabel('Value') | ||
plt.title('Data Plot') | ||
""" | ||
code_with_mod = base_code + "\nplt.savefig('plot.png')" | ||
|
||
code_no_mod = base_code + "\nplt.show()" | ||
|
||
assert get_file_modifications(code_with_mod).modifications == ["plot.png"] | ||
assert get_file_modifications(code_no_mod).modifications == [] | ||
|
||
|
||
if __name__ == "__main__": | ||
# test_remove_download_link() | ||
test_get_file_modifications() |
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