Skip to content

Commit

Permalink
更新百度Search组件的单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
yinjiaqi authored and yinjiaqi committed Nov 7, 2024
1 parent 27e53a2 commit 6296141
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 48 deletions.
21 changes: 21 additions & 0 deletions appbuilder/tests/test_rag_baidu_search_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import unittest
import appbuilder

from appbuilder.core._exception import AppBuilderServerException

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
class TestRagBaiduSearch(unittest.TestCase):
Expand Down Expand Up @@ -71,5 +72,25 @@ def test_rag_with_baidu_search_pro_stream(self):
self.assertTrue(flag_content and flag_ref_content)


def test_rag_with_baidu_search_component_RAGWithBaiduSearch(self):
rwbs=appbuilder.RAGWithBaiduSearch(model='ERNIE-Bot 4.0')

# test_get_search_input
text='text'
res_text=rwbs._get_search_input(text)
self.assertEqual(res_text, 'text')
text='UTF-8是一种变长字节表示的Unicode字符集编码方式,它可以使用1到4个字节来表示一个字符。'
res_text=rwbs._get_search_input(text)
self.assertEqual(res_text, 'UTF-8是一种变长字节表示的Unicode字符集编码方式,它可')

# test run
message=appbuilder.Message()
message.content="""
appbuilderappbuilderappbuilderappbuilderappbuilderappbuilderappbuilderappbuilder
appbuilderappbuilderappbuilderappbuilderappbuilderappbuilderappbuilderappbuilder
"""
with self.assertRaises(AppBuilderServerException):
rwbs.run(message=message)

if __name__ == '__main__':
unittest.main()
48 changes: 0 additions & 48 deletions appbuilder/tests/test_rag_with_baidu_search_component.py

This file was deleted.

0 comments on commit 6296141

Please sign in to comment.