Skip to content

Commit

Permalink
update unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
userpj committed Nov 13, 2024
1 parent f371a1f commit e0966b6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions python/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from unittest.mock import MagicMock
from appbuilder.utils.sse_util import SSEClient,Event
from appbuilder.utils.model_util import RemoteModel,Models
from appbuilder.utils.logger_util import LoggerWithLoggerId,_setup_logging
from appbuilder.utils.logger_util import LoggerWithLoggerId,_setup_logging,logger
from threading import current_thread

# 创建一个logger类
Expand All @@ -40,7 +40,7 @@ def test_sse_util_SSEClient(self):
# 测试是否抛出 StopIteration 异常,表示没有更多事件
with self.assertRaises(StopIteration):
next(event_generator)

# test_events
mock_event_source.__iter__.return_value = iter([
b': Test event 1\n\n',
Expand All @@ -50,28 +50,30 @@ def test_sse_util_SSEClient(self):
b'event:Testevent5\n\n',
])
sse_client = SSEClient(event_source=mock_event_source)
for event in sse_client.events():
pass

logger.setLoglevel("DEBUG")
for event in sse_client.events():
pass
# test_close
sse_client.close()

def test_sse_util_Event(self):
# test_str_
event_str=str(Event(id='id',retry=10))
assert event_str.startswith('message')

def test_model_util_RemoteModel(self):
# test_get_remote_name_by_short_name
rm=RemoteModel(remote_name='test_remote')
rm.get_remote_name_by_short_name(short_name="eb-turbo-appbuilder")

def test_model_util_Models(self):
# test_list
models=Models()
models.list(retry=-1)


if __name__ == '__main__':
unittest.main()


0 comments on commit e0966b6

Please sign in to comment.