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
b04befbb
Commit
b04befbb
authored
Dec 12, 2019
by
sanshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产创建与删除
parent
b3599311
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
45 deletions
+18
-45
test_device_create.py
WorkCase/APP/Device/test_device_create.py
+18
-45
test_device_delete.py
WorkCase/APP/Device/test_device_delete.py
+0
-0
No files found.
WorkCase/APP/Device/test_device_create.py
View file @
b04befbb
...
...
@@ -11,12 +11,7 @@ from WorkUtils.UtilsLog import UtilsLog
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
from
WorkUtils.UtilsResponse
import
UtilsResponse
from
WorkApi.APP.Api.api_login
import
ApiLogin
from
WorkApi.APP.Device.device_create
import
DeviceCreate
from
WorkData.Argus.members
import
DataMembers
from
WorkData.Argus.hosts
import
DataHosts
from
WorkData.Argus.alarm_rule
import
DataAlarmRule
import
allure
from
WorkCase.APP
import
AppBase
...
...
@@ -43,7 +38,7 @@ class TestDeviceCreate(object):
base_dns
=
"sanshi.zmops.com"
base_port
=
161
base_name
=
"SS
操作系统
"
base_name
=
"SS
自动化专用
"
base_business_id_1
=
"12"
base_business_id_2
=
"13"
...
...
@@ -59,28 +54,16 @@ class TestDeviceCreate(object):
def
setup_method
(
self
):
self
.
log
.
debug
(
"测试用例执行开始..."
)
self
.
update_members_del_flag
(
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
del_flag
[
"OFF"
])
self
.
update_members_status
(
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
status
[
"ON"
])
self
.
app
=
AppBase
(
host
=
self
.
host
)
self
.
app
.
update_members_del_flag
(
session
=
self
.
db_session
(),
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
del_flag
[
"OFF"
])
self
.
app
.
update_members_status
(
session
=
self
.
db_session
(),
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
status
[
"ON"
])
self
.
token
=
self
.
app
.
get_base_token
(
login_name
=
self
.
login_name
,
base_password
=
self
.
base_password
)
def
teardown_method
(
self
):
self
.
log
.
debug
(
"测试用例执行结束..."
)
self
.
update_members_del_flag
(
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
del_flag
[
"OFF"
])
self
.
update_members_status
(
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
status
[
"ON"
])
@allure.step
(
"更新表数据:members -- del_flag"
)
def
update_members_del_flag
(
self
,
members_id
=
None
,
value
=
None
):
session
=
self
.
db_session
()
sql
=
DataMembers
()
.
update_del_flag
(
session
=
session
,
_id
=
members_id
,
value
=
value
)
return
sql
@allure.step
(
"更新表数据:members -- status"
)
def
update_members_status
(
self
,
members_id
=
None
,
value
=
None
):
session
=
self
.
db_session
()
sql
=
DataMembers
()
.
update_status
(
session
=
session
,
_id
=
members_id
,
value
=
value
)
return
sql
self
.
app
.
update_members_del_flag
(
session
=
self
.
db_session
(),
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
del_flag
[
"OFF"
])
self
.
app
.
update_members_status
(
session
=
self
.
db_session
(),
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
status
[
"ON"
])
@allure.step
(
"连接数据库:Argus"
)
def
db_session
(
self
):
...
...
@@ -139,41 +122,31 @@ class TestDeviceCreate(object):
assert
y
.
host_name
==
name
assert
y
.
monitor_type
==
monitor_type
@allure.step
(
"断言返回结果"
)
def
check_code
(
self
,
response
,
code
):
_code
=
UtilsResponse
()
.
get_code
(
response
=
response
)
assert
_code
==
code
@allure.step
(
"断言返回结果数据"
)
def
check_msg
(
self
,
response
,
msg
):
_msg
=
UtilsResponse
()
.
get_msg
(
response
=
response
)
assert
_msg
==
msg
@allure.title
(
"device.create:token未传"
)
@allure.story
(
"创建资产:token未传"
)
@allure.severity
(
"blocker"
)
def
test_case_01
(
self
):
response
=
self
.
app
.
device_create
()
self
.
check_code
(
response
=
response
,
code
=
2001
)
self
.
check_msg
(
response
=
response
,
msg
=
"无token,请重新登录"
)
self
.
app
.
check_code
(
response
=
response
,
code
=
2001
)
self
.
app
.
check_msg
(
response
=
response
,
msg
=
"无token,请重新登录"
)
@allure.title
(
"device.create:token的用户已删除"
)
@allure.story
(
"创建资产:token的用户已删除"
)
@allure.severity
(
"blocker"
)
def
test_case_02
(
self
):
self
.
update_members_del_flag
(
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
del_flag
[
"ON"
])
self
.
app
.
update_members_del_flag
(
session
=
self
.
db_session
(),
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
del_flag
[
"ON"
])
response
=
self
.
app
.
device_create
(
token
=
self
.
token
)
self
.
check_code
(
response
=
response
,
code
=
2004
)
self
.
check_msg
(
response
=
response
,
msg
=
"用户不存在"
)
self
.
app
.
check_code
(
response
=
response
,
code
=
2004
)
self
.
app
.
check_msg
(
response
=
response
,
msg
=
"用户不存在"
)
@allure.title
(
"device.create:token的用户已禁用"
)
@allure.story
(
"创建资产:token的用户已禁用"
)
@allure.severity
(
"blocker"
)
def
test_case_03
(
self
):
self
.
update_members_status
(
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
status
[
"OFF"
])
self
.
app
.
update_members_status
(
session
=
self
.
db_session
(),
members_id
=
self
.
base_id
,
value
=
CaseBase
()
.
status
[
"OFF"
])
response
=
self
.
app
.
device_create
(
token
=
self
.
token
)
self
.
check_code
(
response
=
response
,
code
=
2003
)
self
.
check_msg
(
response
=
response
,
msg
=
"账户已被禁用"
)
self
.
app
.
check_code
(
response
=
response
,
code
=
2003
)
self
.
app
.
check_msg
(
response
=
response
,
msg
=
"账户已被禁用"
)
@allure.title
(
"device.create:创建agent资产,ip识别"
)
@allure.story
(
"创建资产:创建agent资产,ip识别"
)
...
...
@@ -183,7 +156,7 @@ 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
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
1
)
@allure.title
(
"device.create:创建agent资产,dns识别"
)
...
...
@@ -194,7 +167,7 @@ class TestDeviceCreate(object):
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_agent
,
iplist
=
self
.
base_ip
,
dns
=
self
.
base_dns
,
monitorInterface
=
self
.
base_port
,
monitorType
=
2
,
manageLevel
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
2
)
@allure.title
(
"device.create:创建snmp资产,ip识别"
)
...
...
@@ -205,7 +178,7 @@ 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
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
1
)
@allure.title
(
"device.create:创建snmp资产,dns识别"
)
...
...
@@ -216,7 +189,7 @@ class TestDeviceCreate(object):
response
=
self
.
app
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_snmp
,
iplist
=
self
.
base_ip
,
dns
=
self
.
base_dns
,
monitorInterface
=
self
.
base_port
,
monitorType
=
2
,
manageLevel
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_monitor_type
(
response
=
response
,
name
=
name
,
monitor_type
=
2
)
@allure.title
(
"device.create:创建资产-所有字段"
)
...
...
@@ -231,7 +204,7 @@ class TestDeviceCreate(object):
ipmiAuthtype
=
1
,
ipmiPrivilege
=
1
,
ipmiUsername
=
"ipmiUsername"
,
ipmiPassword
=
"ipmiPassword"
,
factoryId
=
1
,
model
=
"model"
,
version
=
"version"
,
serialnumber
=
"serialnumber"
,
description
=
"description"
,
monitorStatus
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
app
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_select
(
response
=
response
,
name
=
name
,
manage_ip
=
self
.
base_ip
,
manage_level
=
1
,
host_type
=
self
.
base_type_agent
,
monitor_status
=
1
,
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
,
...
...
WorkCase/APP/Device/test_device_delete.py
View file @
b04befbb
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