Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
5190421f
Commit
5190421f
authored
5 years ago
by
Никита Ефремов
Committed by
Nick Yefremov
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added interactive tests interface
parent
88ec17e9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
17 deletions
+35
-17
test.py
test.py
+35
-17
No files found.
test.py
View file @
5190421f
import
subprocess
as
sbp
from
unittest
import
TestCase
,
main
import
xml.etree.ElementTree
as
ET
from
pprint
import
pprint
as
pp
from
dbus
import
SystemBus
sep
=
"
\n
"
+
"-"
*
30
+
"
\n
"
list_
=
[
"common_info"
,
"date_time"
,
"dnsmasq_config"
,
"example"
,
"local_groups"
,
"local_users"
,
"
machine"
,
"
network"
,
"nss_roles"
,
"local_groups"
,
"local_users"
,
"network"
,
"nss_roles"
,
"ntp_config"
,
"package_updates"
,
"rtorrentd_config"
,
"ssl"
,
"statistics"
,
"system_services"
]
cmd
=
"dbus-send --system --type=method_call --print-reply
\
--dest=org.etersoft.settingsd /org/etersoft/settingsd/functions/{func_name}
\
org.etersoft.settingsd.functions.{funcName}.{interface}.{method} {args}"
class
TestSettingsdMain
(
TestCase
):
def
test_common_info
(
self
):
res
=
sbp
.
run
(
cmd
.
format
(
func_name
=
"common_info"
,
funcName
=
"commonInfo"
,
interface
=
"lsbRelease"
,
method
=
"version"
,
args
=
""
),
stdout
=
sbp
.
PIPE
)
res
=
res
.
stdout
.
decode
(
'utf-8'
)
print
(
res
)
if
__name__
==
'__main__'
:
main
()
class
TestSettingsdMain
():
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
dbus
=
SystemBus
()
self
.
log_file
=
open
(
"test_log.log"
,
"w"
)
def
test_all
(
self
):
for
module_name
in
list_
:
remote_object
=
dbus
.
get_object
(
"org.etersoft.settingsd"
,
"/org/etersoft/settingsd/functions/{}"
.
format
(
module_name
))
remote_object
.
Introspect
()
for
method_name
,
args
in
remote_object
.
__dict__
[
'_introspect_method_map'
]
.
items
():
if
args
!=
""
and
args
!=
" "
:
print
(
"Test with arguments:"
,
"."
.
join
((
method_name
.
rsplit
(
"."
,
3
)[
1
:])))
try
:
print
(
"Testing: "
,
"."
.
join
((
method_name
.
rsplit
(
"."
,
3
)[
1
:])),
"
\n
Proceed test? (y/n)"
)
confirmaion
=
input
()
if
confirmaion
==
"y"
:
print
(
"Output: "
,
remote_object
.
__getattr__
(
method_name
.
rsplit
(
"."
,
1
)[
1
])(),
sep
)
else
:
print
(
"Skipped...."
+
sep
)
continue
except
Exception
as
e
:
print
(
sep
,
str
(
e
),
sep
)
self
.
log_file
.
write
(
sep
+
str
(
e
)
+
sep
)
self
.
log_file
.
close
()
dbus
=
SystemBus
()
t
=
TestSettingsdMain
()
t
.
test_all
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment