Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zmops-test
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sanshi
zmops-test
Commits
66dd2075
Commit
66dd2075
authored
Dec 18, 2019
by
sanshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整个业务代码重构
parent
bee4ada3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
18 deletions
+23
-18
test_host_create.py
WorkCase/API/Host/test_host_create.py
+17
-14
test_host_delete.py
WorkCase/API/Host/test_host_delete.py
+2
-1
test_host_get.py
WorkCase/API/Host/test_host_get.py
+2
-1
test_host_update.py
WorkCase/API/Host/test_host_update.py
+2
-2
No files found.
WorkCase/API/Host/test_host_create.py
View file @
66dd2075
...
...
@@ -37,6 +37,7 @@ class TestHostCreate(object):
base_group_id
=
99
base_name
=
"SS TEST HOST CREATE"
base_ip
=
"172.16.3.170"
base_port
=
"161"
base_host
=
"SS测试主机"
base_description
=
"SS测试主机描述"
...
...
@@ -136,7 +137,7 @@ class TestHostCreate(object):
sql
=
self
.
select_interface
(
hostid
=
hostid
)
for
x
,
y
in
enumerate
(
sql
):
assert
y
.
ip
==
self
.
base_ip
assert
y
.
port
==
"100"
assert
y
.
port
==
self
.
base_port
assert
y
.
type
==
_type
assert
y
.
main
==
1
...
...
@@ -157,7 +158,7 @@ class TestHostCreate(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_group_id
],
interfaces
=
[
interfaces
],
status
=
0
)
...
...
@@ -177,7 +178,7 @@ class TestHostCreate(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_group_id
],
interfaces
=
[
interfaces
],
status
=
0
)
...
...
@@ -196,7 +197,7 @@ class TestHostCreate(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
101
],
interfaces
=
[
interfaces
],
status
=
0
)
...
...
@@ -217,7 +218,7 @@ class TestHostCreate(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
101
],
interfaces
=
[
interfaces
],
status
=
0
,
templateids
=
[
templateid
],
...
...
@@ -226,8 +227,8 @@ class TestHostCreate(object):
"value"
:
"public"
}])
self
.
check_code
(
response
=
response
,
code
=
0
)
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
check_host
(
hostid
=
hostid
,
templateid
=
templateid
)
#
hostid = UtilsResponse().get_result(response=response)["hostids"][0]
#
self.check_host(hostid=hostid, templateid=templateid)
@allure.title
(
"host.create:模板创建 snmp"
)
@allure.story
(
"创建主机:模板创建 snmp"
)
...
...
@@ -242,7 +243,7 @@ class TestHostCreate(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
101
],
interfaces
=
[
interfaces
],
status
=
0
,
templateids
=
[
templateid
],
...
...
@@ -251,8 +252,8 @@ class TestHostCreate(object):
"value"
:
"public"
}])
self
.
check_code
(
response
=
response
,
code
=
0
)
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
check_host
(
hostid
=
hostid
,
templateid
=
templateid
)
#
hostid = UtilsResponse().get_result(response=response)["hostids"][0]
#
self.check_host(hostid=hostid, templateid=templateid)
@allure.step
(
"校验创建host的相关数据"
)
def
check_host
(
self
,
hostid
,
templateid
):
...
...
@@ -266,22 +267,24 @@ class TestHostCreate(object):
triggers
=
[]
for
x
,
y
in
enumerate
(
itemids
):
sql
=
self
.
select_functions
(
itemid
=
y
)
if
sql
:
triggers
.
append
(
sql
[
0
]
.
triggerid
)
for
q
,
w
in
enumerate
(
sql
)
:
triggers
.
append
(
w
.
triggerid
)
new_itemids
=
[]
self
.
log
.
info
(
"校验监控项是否根据模板监控器已创建"
)
for
x
,
y
in
enumerate
(
itemids
):
sql
=
self
.
select_items
(
hostid
=
hostid
,
templateid
=
y
)
assert
sql
!=
[]
new_itemids
.
append
(
sql
[
0
]
.
itemid
)
for
q
,
w
in
enumerate
(
sql
):
new_itemids
.
append
(
w
.
itemid
)
new_triggers
=
[]
self
.
log
.
info
(
"校验触发器是否根据模板触发器已创建"
)
for
x
,
y
in
enumerate
(
triggers
):
sql
=
self
.
select_triggers
(
templateid
=
y
)
assert
sql
!=
[]
new_triggers
.
append
(
sql
[
0
]
.
triggerid
)
for
q
,
w
in
enumerate
(
sql
):
new_triggers
.
append
(
w
.
triggerid
)
self
.
log
.
info
(
"校验监控器与触发器关系是否已创建"
)
for
x
,
y
in
enumerate
(
new_triggers
):
...
...
WorkCase/API/Host/test_host_delete.py
View file @
66dd2075
...
...
@@ -33,6 +33,7 @@ class TestHostDelete(object):
base_groupid
=
99
base_name
=
"SS TEST HOST DELETE"
base_ip
=
"172.16.3.170"
base_port
=
"161"
base_description
=
"SS自动化测试主机描述, 请勿删除"
@classmethod
...
...
@@ -128,7 +129,7 @@ class TestHostDelete(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
161
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_groupid
],
...
...
WorkCase/API/Host/test_host_get.py
View file @
66dd2075
...
...
@@ -35,6 +35,7 @@ class TestHostGet(object):
base_groupid
=
99
base_name
=
"SS TEST HOST GET"
base_ip
=
"172.16.3.170"
base_port
=
"161"
base_description
=
"SS自动化测试主机描述, 请勿删除"
@classmethod
...
...
@@ -143,7 +144,7 @@ class TestHostGet(object):
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
161
,
"port"
:
self
.
base_port
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_groupid
],
...
...
WorkCase/API/Host/test_host_update.py
View file @
66dd2075
...
...
@@ -35,7 +35,7 @@ class TestHostUpdate(object):
base_groupid
=
99
base_name
=
"SS TEST HOST UPDATE"
base_ip
=
"172.16.3.170"
base_port
=
161
base_port
=
"161"
base_description
=
"SS自动化测试主机描述, 请勿删除"
@classmethod
...
...
@@ -202,7 +202,7 @@ class TestHostUpdate(object):
assert
y
.
useip
==
1
assert
y
.
ip
==
self
.
base_ip
assert
y
.
dns
==
""
assert
int
(
y
.
port
)
==
self
.
base_port
assert
y
.
port
==
self
.
base_port
assert
x
==
0
@allure.title
(
"host.update:需要的字段"
)
...
...
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