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
a9bf4edf
Commit
a9bf4edf
authored
Dec 16, 2019
by
sanshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整个业务代码重构
parent
61f691c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
7 deletions
+46
-7
test_device_create.py
WorkCase/APP/Device/test_device_create.py
+46
-7
No files found.
WorkCase/APP/Device/test_device_create.py
View file @
a9bf4edf
...
...
@@ -12,6 +12,7 @@ from WorkUtils.UtilsDataBase import UtilsDataBase
from
WorkUtils.UtilsResponse
import
UtilsResponse
from
WorkData.Argus.hosts
import
DataHosts
from
WorkData.Zabbix.interface
import
DataInterface
import
allure
from
WorkCase.APP
import
AppBase
...
...
@@ -27,13 +28,14 @@ class TestDeviceCreate(object):
db_user
=
env
[
"db_user"
]
db_pw
=
env
[
"db_pw"
]
db_base
=
env
[
"db_base"
]
db_base_zabbix
=
env
[
"db_base_zabbix"
]
login_name
=
"SS测试用户名"
base_id
=
10
base_password
=
"123456"
base_type_agent
=
12
8
base_type_snmp
=
12
9
base_type_agent
=
12
6
base_type_snmp
=
12
7
base_ip
=
"172.16.3.170"
base_dns
=
"sanshi.zmops.com"
base_port
=
161
...
...
@@ -70,17 +72,41 @@ class TestDeviceCreate(object):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
self
.
db_url
,
db_port
=
self
.
db_port
,
db_base
=
self
.
db_base
,
db_user
=
self
.
db_user
,
db_pw
=
self
.
db_pw
)
return
session
@allure.step
(
"连接数据库:Zabbix"
)
def
db_session_zabbix
(
self
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
self
.
db_url
,
db_port
=
self
.
db_port
,
db_base
=
self
.
db_base_zabbix
,
db_user
=
self
.
db_user
,
db_pw
=
self
.
db_pw
)
return
session
@allure.step
(
"查询表:hosts"
)
def
select_hosts
(
self
,
hostid
=
None
,
host_name
=
None
,
available
=
None
,
monitor_status
=
None
):
session
=
self
.
db_session
()
sql
=
DataHosts
()
.
select_all_from_allKeys
(
session
=
session
,
hostid
=
hostid
,
host_name
=
host_name
,
available
=
available
,
monitor_status
=
monitor_status
)
return
sql
@allure.step
(
"查询表:interface"
)
def
select_interface
(
self
,
hostid
=
None
):
session
=
self
.
db_session_zabbix
()
sql
=
DataInterface
()
.
select_all_from_allKeys
(
session
=
session
,
hostid
=
hostid
)
return
sql
@allure.step
(
"校验Zabbix接口数据"
)
def
check_interface
(
self
,
host_id
,
_type
,
useip
,
ip
,
dns
,
port
):
sql
=
self
.
select_interface
(
hostid
=
host_id
)
assert
sql
!=
[]
for
x
,
y
in
enumerate
(
sql
):
assert
y
.
main
==
1
assert
y
.
type
==
_type
assert
y
.
useip
==
useip
assert
y
.
ip
==
ip
assert
y
.
dns
==
dns
assert
y
.
port
==
str
(
port
)
assert
x
==
0
@allure.step
(
"校验查询结果"
)
def
check_select
(
self
,
response
,
name
,
manage_ip
,
manage_level
,
host_type
,
parent_host
,
monitor_status
,
iplist
,
dns
,
monitor_interface
,
ops_person
,
factoryId
,
model
,
version
,
serialnumber
,
description
,
snmp_community
,
ipmi_authtype
,
ipmi_privilege
,
ipmi_username
,
ipmi_password
,
businessIds
,
businessTree
):
ipmi_username
,
ipmi_password
,
businessIds
,
hostTypeTree
,
businessTree
):
data
=
UtilsResponse
()
.
get_data
(
response
=
response
)
sql
=
self
.
select_hosts
(
hostid
=
data
)
assert
sql
!=
[]
...
...
@@ -98,6 +124,7 @@ class TestDeviceCreate(object):
assert
y
.
dns
==
dns
assert
int
(
y
.
monitor_interface
)
==
monitor_interface
assert
y
.
business_ids
==
businessIds
assert
y
.
host_type_tree
==
hostTypeTree
assert
y
.
business_tree
==
businessTree
# assert y.port == port
assert
y
.
ops_person
==
ops_person
...
...
@@ -156,8 +183,10 @@ class TestDeviceCreate(object):
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_agent
,
iplist
=
self
.
base_ip
,
monitorInterface
=
self
.
base_port
,
monitorType
=
1
,
manageLevel
=
1
)
host_id
=
UtilsResponse
()
.
get_data
(
response
=
response
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
1
)
self
.
check_interface
(
host_id
=
host_id
,
_type
=
1
,
useip
=
1
,
ip
=
self
.
base_ip
,
dns
=
""
,
port
=
self
.
base_port
)
@allure.title
(
"device.create:创建agent资产,dns识别"
)
@allure.story
(
"创建资产:创建agent资产,dns识别"
)
...
...
@@ -165,10 +194,12 @@ class TestDeviceCreate(object):
def
test_case_05
(
self
):
name
=
self
.
base_name
+
"05"
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_agent
,
iplist
=
self
.
base_ip
,
dns
=
self
.
base_dns
,
dns
=
self
.
base_dns
,
monitorInterface
=
self
.
base_port
,
monitorType
=
2
,
manageLevel
=
1
)
host_id
=
UtilsResponse
()
.
get_data
(
response
=
response
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
2
)
self
.
check_interface
(
host_id
=
host_id
,
_type
=
1
,
useip
=
0
,
ip
=
""
,
dns
=
self
.
base_dns
,
port
=
self
.
base_port
)
@allure.title
(
"device.create:创建snmp资产,ip识别"
)
@allure.story
(
"创建资产:创建snmp资产,ip识别"
)
...
...
@@ -178,8 +209,10 @@ class TestDeviceCreate(object):
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_snmp
,
iplist
=
self
.
base_ip
,
monitorInterface
=
self
.
base_port
,
monitorType
=
1
,
manageLevel
=
1
)
host_id
=
UtilsResponse
()
.
get_data
(
response
=
response
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
1
)
self
.
check_interface
(
host_id
=
host_id
,
_type
=
2
,
useip
=
1
,
ip
=
self
.
base_ip
,
dns
=
""
,
port
=
self
.
base_port
)
@allure.title
(
"device.create:创建snmp资产,dns识别"
)
@allure.story
(
"创建资产:创建snmp资产,dns识别"
)
...
...
@@ -187,10 +220,12 @@ class TestDeviceCreate(object):
def
test_case_07
(
self
):
name
=
self
.
base_name
+
"07"
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_snmp
,
iplist
=
self
.
base_ip
,
dns
=
self
.
base_dns
,
dns
=
self
.
base_dns
,
monitorInterface
=
self
.
base_port
,
monitorType
=
2
,
manageLevel
=
1
)
host_id
=
UtilsResponse
()
.
get_data
(
response
=
response
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
2
)
self
.
check_interface
(
host_id
=
host_id
,
_type
=
2
,
useip
=
0
,
ip
=
""
,
dns
=
self
.
base_dns
,
port
=
self
.
base_port
)
@allure.title
(
"device.create:创建资产-所有字段"
)
@allure.story
(
"创建资产:创建资产-所有字段"
)
...
...
@@ -199,7 +234,9 @@ class TestDeviceCreate(object):
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_agent
,
iplist
=
self
.
base_ip
,
monitorInterface
=
self
.
base_port
,
monitorType
=
1
,
manageLevel
=
1
,
parentHost
=
1
,
businessIds
=
self
.
base_business_id_1
+
","
+
self
.
base_business_id_2
,
businessTree
=
"businessTree"
,
businessIds
=
self
.
base_business_id_1
+
","
+
self
.
base_business_id_2
,
hostTypeTree
=
"hostTypeTree"
,
businessTree
=
"businessTree"
,
opsPerson
=
11
,
snmpCommunity
=
"snmpCommunity"
,
ipmiAuthtype
=
1
,
ipmiPrivilege
=
1
,
ipmiUsername
=
"ipmiUsername"
,
ipmiPassword
=
"ipmiPassword"
,
factoryId
=
1
,
model
=
"model"
,
version
=
"version"
,
serialnumber
=
"serialnumber"
,
description
=
"description"
,
...
...
@@ -209,7 +246,9 @@ class TestDeviceCreate(object):
iplist
=
self
.
base_ip
,
dns
=
None
,
monitor_interface
=
self
.
base_port
,
ops_person
=
11
,
snmp_community
=
"snmpCommunity"
,
ipmi_authtype
=
1
,
ipmi_privilege
=
1
,
ipmi_username
=
"ipmiUsername"
,
ipmi_password
=
"ipmiPassword"
,
parent_host
=
1
,
factoryId
=
1
,
model
=
"model"
,
version
=
"version"
,
serialnumber
=
"serialnumber"
,
description
=
"description"
,
businessIds
=
self
.
base_business_id_1
+
","
+
self
.
base_business_id_2
,
businessTree
=
"businessTree"
)
businessIds
=
self
.
base_business_id_1
+
","
+
self
.
base_business_id_2
,
hostTypeTree
=
"hostTypeTree"
,
businessTree
=
"businessTree"
)
if
__name__
==
"__main__"
:
...
...
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