Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
44791692
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
44791692
编写于
6月 05, 2018
作者:
R
Radek Duda
提交者:
Lukáš Doktor
6月 12, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test_utils_service: wrap long lines
Signed-off-by:
N
Radek Duda
<
rduda@redhat.com
>
上级
abadecb2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
20 deletion
+37
-20
selftests/unit/test_utils_service.py
selftests/unit/test_utils_service.py
+37
-20
未找到文件。
selftests/unit/test_utils_service.py
浏览文件 @
44791692
...
...
@@ -69,7 +69,8 @@ class TestSystemd(unittest.TestCase):
cmd
=
"is-enabled"
if
cmd
==
"reset_failed"
:
cmd
=
"reset-failed"
self
.
assertEqual
(
ret
,
[
"systemctl"
,
cmd
,
"%s.service"
%
self
.
service_name
])
self
.
assertEqual
(
ret
,
[
"systemctl"
,
cmd
,
"%s.service"
%
self
.
service_name
])
def
test_set_target
(
self
):
ret
=
getattr
(
...
...
@@ -160,7 +161,8 @@ class TestServiceManager(unittest.TestCase):
service_command_generator
=
service
.
_ServiceCommandGenerator
(
command_generator
)
service_result_parser
=
service
.
_ServiceResultParser
(
result_parser
)
return
service_manager
(
service_command_generator
,
service_result_parser
,
run_mock
)
return
service_manager
(
service_command_generator
,
service_result_parser
,
run_mock
)
class
TestSystemdServiceManager
(
TestServiceManager
):
...
...
@@ -168,9 +170,10 @@ class TestSystemdServiceManager(TestServiceManager):
def
setUp
(
self
):
self
.
run_mock
=
mock
.
Mock
()
self
.
init_name
=
"systemd"
self
.
service_manager
=
super
(
TestSystemdServiceManager
,
self
).
get_service_manager_from_init_and_run
(
self
.
init_name
,
self
.
run_mock
)
self
.
service_manager
=
\
(
super
(
TestSystemdServiceManager
,
self
)
.
get_service_manager_from_init_and_run
(
self
.
init_name
,
self
.
run_mock
))
def
test_start
(
self
):
srv
=
"lldpad"
...
...
@@ -184,12 +187,13 @@ class TestSystemdServiceManager(TestServiceManager):
"vsftpd.service disabled
\n
"
"systemd-sysctl.service static
\n
"
)
run_mock
=
mock
.
Mock
(
return_value
=
list_result_mock
)
service_manager
=
super
(
TestSystemdServiceManager
,
self
).
get_service_manager_from_init_and_run
(
self
.
init_name
,
run_mock
)
service_manager
=
\
(
super
(
TestSystemdServiceManager
,
self
)
.
get_service_manager_from_init_and_run
(
self
.
init_name
,
run_mock
)
)
list_result
=
service_manager
.
list
(
ignore_status
=
False
)
self
.
assertEqual
(
run_mock
.
call_args
[
0
][
0
],
"systemctl list-unit-files --type=service --no-pager --full"
)
"systemctl list-unit-files --type=service "
"--no-pager --full"
)
self
.
assertEqual
(
list_result
,
{
'sshd'
:
"enabled"
,
'vsftpd'
:
"disabled"
,
'systemd-sysctl'
:
"static"
})
...
...
@@ -229,28 +233,41 @@ class TestSysVInitServiceManager(TestServiceManager):
def
setUp
(
self
):
self
.
run_mock
=
mock
.
Mock
()
self
.
init_name
=
"init"
self
.
service_manager
=
super
(
TestSysVInitServiceManager
,
self
).
get_service_manager_from_init_and_run
(
self
.
init_name
,
self
.
run_mock
)
self
.
service_manager
=
\
super
(
TestSysVInitServiceManager
,
self
).
get_service_manager_from_init_and_run
(
self
.
init_name
,
self
.
run_mock
)
def
test_start
(
self
):
srv
=
"lldpad"
self
.
service_manager
.
start
(
srv
)
cmd
=
(
"service %s start"
%
srv
)
self
.
assertEqual
(
self
.
run_mock
.
call_args
[
0
][
0
],
cmd
)
def
test_list
(
self
):
list_result_mock
=
mock
.
Mock
(
exit_status
=
0
,
stdout
=
"sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
\n
"
"vsftpd 0:off 1:off 2:off 3:off 4:off 5:on 6:off
\n
"
stdout
=
"sshd 0:off 1:off "
"2:off 3:off 4:off 5:off 6:off
\n
"
"vsftpd 0:off 1:off 2:off "
" 3:off 4:off 5:on 6:off
\n
"
"xinetd based services:
\n
"
" amanda: off
\n
"
" chargen-dgram: on
\n
"
)
run_mock
=
mock
.
Mock
(
return_value
=
list_result_mock
)
service_manager
=
super
(
TestSysVInitServiceManager
,
self
).
get_service_manager_from_init_and_run
(
self
.
init_name
,
run_mock
)
service_manager
=
\
super
(
TestSysVInitServiceManager
,
self
).
get_service_manager_from_init_and_run
(
self
.
init_name
,
run_mock
)
list_result
=
service_manager
.
list
(
ignore_status
=
False
)
self
.
assertEqual
(
run_mock
.
call_args
[
0
][
0
],
"chkconfig --list"
)
self
.
assertEqual
(
list_result
,
{
'sshd'
:
{
0
:
"off"
,
1
:
"off"
,
2
:
"off"
,
3
:
"off"
,
4
:
"off"
,
5
:
"off"
,
6
:
"off"
},
'vsftpd'
:
{
0
:
"off"
,
1
:
"off"
,
2
:
"off"
,
3
:
"off"
,
4
:
"off"
,
5
:
"on"
,
6
:
"off"
},
'xinetd'
:
{
'amanda'
:
"off"
,
'chargen-dgram'
:
"on"
}})
self
.
assertEqual
(
list_result
,
{
'sshd'
:
{
0
:
"off"
,
1
:
"off"
,
2
:
"off"
,
3
:
"off"
,
4
:
"off"
,
5
:
"off"
,
6
:
"off"
},
'vsftpd'
:
{
0
:
"off"
,
1
:
"off"
,
2
:
"off"
,
3
:
"off"
,
4
:
"off"
,
5
:
"on"
,
6
:
"off"
},
'xinetd'
:
{
'amanda'
:
"off"
,
'chargen-dgram'
:
"on"
}})
def
test_enable
(
self
):
srv
=
"lldpad"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录