Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
C
ComfyUI
管理
动态
成员
代码
仓库
分支
提交
标签
仓库图
比较修订版本
锁定的文件
部署
模型注册表
分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
Show more breadcrumbs
hanamizuki
ComfyUI
提交
db9f2a34
提交
db9f2a34
编辑于
4天前
作者:
Chenlei Hu
浏览文件
操作
下载
补丁
差异文件
Fix unit test
上级
79460497
分支
ignore_fe_package
分支 包含提交
No related tags found
无相关合并请求
变更
1
隐藏空白变更内容
行内
左右并排
显示
1 个更改的文件
tests-unit/app_test/frontend_manager_test.py
+51
-6
51 个添加, 6 个删除
tests-unit/app_test/frontend_manager_test.py
有
51 个添加
和
6 个删除
tests-unit/app_test/frontend_manager_test.py
+
51
−
6
浏览文件 @
db9f2a34
...
...
@@ -70,7 +70,7 @@ def test_get_release_invalid_version(mock_provider):
def
test_init_frontend_default
():
version_string
=
DEFAULT_VERSION_STRING
frontend_path
=
FrontendManager
.
init_frontend
(
version_string
)
assert
frontend_path
==
FrontendManager
.
DEFAULT_FRONTEND_PATH
assert
frontend_path
==
FrontendManager
.
default_frontend_path
()
def
test_init_frontend_invalid_version
():
...
...
@@ -84,24 +84,29 @@ def test_init_frontend_invalid_provider():
with
pytest
.
raises
(
HTTPError
):
FrontendManager
.
init_frontend_unsafe
(
version_string
)
@pytest.fixture
def
mock_os_functions
():
with
patch
(
'
app.frontend_management.os.makedirs
'
)
as
mock_makedirs
,
\
patch
(
'
app.frontend_management.os.listdir
'
)
as
mock_listdir
,
\
patch
(
'
app.frontend_management.os.rmdir
'
)
as
mock_rmdir
:
with
(
patch
(
"
app.frontend_management.os.makedirs
"
)
as
mock_makedirs
,
patch
(
"
app.frontend_management.os.listdir
"
)
as
mock_listdir
,
patch
(
"
app.frontend_management.os.rmdir
"
)
as
mock_rmdir
,
):
mock_listdir
.
return_value
=
[]
# Simulate empty directory
yield
mock_makedirs
,
mock_listdir
,
mock_rmdir
@pytest.fixture
def
mock_download
():
with
patch
(
'
app.frontend_management.download_release_asset_zip
'
)
as
mock
:
with
patch
(
"
app.frontend_management.download_release_asset_zip
"
)
as
mock
:
mock
.
side_effect
=
Exception
(
"
Download failed
"
)
# Simulate download failure
yield
mock
def
test_finally_block
(
mock_os_functions
,
mock_download
,
mock_provider
):
# Arrange
mock_makedirs
,
mock_listdir
,
mock_rmdir
=
mock_os_functions
version_string
=
'
test-owner/test-repo@1.0.0
'
version_string
=
"
test-owner/test-repo@1.0.0
"
# Act & Assert
with
pytest
.
raises
(
Exception
):
...
...
@@ -128,3 +133,43 @@ def test_parse_version_string_invalid():
version_string
=
"
invalid
"
with
pytest
.
raises
(
argparse
.
ArgumentTypeError
):
FrontendManager
.
parse_version_string
(
version_string
)
def
test_init_frontend_default_with_mocks
():
# Arrange
version_string
=
DEFAULT_VERSION_STRING
# Act
with
(
patch
(
"
app.frontend_management.check_frontend_version
"
)
as
mock_check
,
patch
.
object
(
FrontendManager
,
"
default_frontend_path
"
,
return_value
=
"
/mocked/path
"
),
):
frontend_path
=
FrontendManager
.
init_frontend
(
version_string
)
# Assert
assert
frontend_path
==
"
/mocked/path
"
mock_check
.
assert_called_once
()
def
test_init_frontend_fallback_on_error
():
# Arrange
version_string
=
"
test-owner/test-repo@1.0.0
"
# Act
with
(
patch
.
object
(
FrontendManager
,
"
init_frontend_unsafe
"
,
side_effect
=
Exception
(
"
Test error
"
)
),
patch
(
"
app.frontend_management.check_frontend_version
"
)
as
mock_check
,
patch
.
object
(
FrontendManager
,
"
default_frontend_path
"
,
return_value
=
"
/default/path
"
),
):
frontend_path
=
FrontendManager
.
init_frontend
(
version_string
)
# Assert
assert
frontend_path
==
"
/default/path
"
mock_check
.
assert_called_once
()
This diff is collapsed.
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录