Commit 5a5ea5c5 by sanshi

优化主机接口模块

设备新增测试
parent c5b17efd
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<w>hstgrp</w> <w>hstgrp</w>
<w>interfaceid</w> <w>interfaceid</w>
<w>interfaceids</w> <w>interfaceids</w>
<w>iplist</w>
<w>ipmi</w> <w>ipmi</w>
<w>itemid</w> <w>itemid</w>
<w>itemids</w> <w>itemids</w>
...@@ -66,6 +67,7 @@ ...@@ -66,6 +67,7 @@
<w>scrapy</w> <w>scrapy</w>
<w>securitylevel</w> <w>securitylevel</w>
<w>securityname</w> <w>securityname</w>
<w>serialnumber</w>
<w>serviceids</w> <w>serviceids</w>
<w>snmpv</w> <w>snmpv</w>
<w>sortfield</w> <w>sortfield</w>
......
# -*- coding: utf-8 -*-
# 创建资产
# 作者: 陈磊
# 时间: 2019-11-25
from WorkUtils.UtilsRequest import UtilsRequest
from WorkUtils.UtilsLog import UtilsLog
from WorkApi.ApiBase import ApiBase, GetBase
class DeviceCreate(object):
def __init__(self, _host):
"""
:param _host: 域名
:return:
"""
self.log = UtilsLog()
self.log.info("调用创建资产")
self.log.info(self.__class__)
self._host = _host
self._headers = {}
self._path = "/device/create"
self._url = self._host + self._path
self._params = {}
self._json = {}
self._data = {}
self.response = ""
self.token = None
self.hostName = None
self.hostType = None
self.iplist = None
self.dns = None
self.monitorInterface = None
self.monitorType = None
self.parentHost = None
self.businessIds = None
self.opsPerson = None
self.snmpCommunity = None
self.ipmiAuthtype = None
self.ipmiPrivilege = None
self.ipmiUsername = None
self.ipmiPassword = None
self.factory = None
self.model = None
self.version = None
self.serialnumber = None
self.description = None
self.monitorStatus = None
self.api = UtilsRequest()
def get_response(self):
base = ApiBase()
base.dict_add_key(_key="token", value=self.token)
self._headers = base._json
base = ApiBase()
base.dict_add_key(_key="hostName", value=self.hostName)
base.dict_add_key(_key="hostType", value=self.hostType)
base.dict_add_key(_key="iplist", value=self.iplist)
base.dict_add_key(_key="dns", value=self.dns)
base.dict_add_key(_key="monitorInterface", value=self.monitorInterface)
base.dict_add_key(_key="monitorType", value=self.monitorType)
base.dict_add_key(_key="parentHost", value=self.parentHost)
base.dict_add_key(_key="businessIds", value=self.businessIds)
base.dict_add_key(_key="opsPerson", value=self.opsPerson)
base.dict_add_key(_key="snmpCommunity", value=self.snmpCommunity)
base.dict_add_key(_key="ipmiAuthtype", value=self.ipmiAuthtype)
base.dict_add_key(_key="ipmiPrivilege", value=self.ipmiPrivilege)
base.dict_add_key(_key="ipmiUsername", value=self.ipmiUsername)
base.dict_add_key(_key="ipmiPassword", value=self.ipmiPassword)
base.dict_add_key(_key="factory", value=self.factory)
base.dict_add_key(_key="model", value=self.model)
base.dict_add_key(_key="version", value=self.version)
base.dict_add_key(_key="serialnumber", value=self.serialnumber)
base.dict_add_key(_key="description", value=self.description)
base.dict_add_key(_key="monitorStatus", value=self.monitorStatus)
self._json = base._json
self.response = self.api.post(url=self._url, headers=self._headers, json=self._json)
...@@ -6,18 +6,19 @@ ...@@ -6,18 +6,19 @@
from __future__ import division from __future__ import division
from WorkApi.API.Host.host_create import HostCreate
from WorkCase import CaseBase from WorkCase import CaseBase
from WorkUtils.UtilsLog import UtilsLog from WorkUtils.UtilsLog import UtilsLog
from WorkUtils.UtilsDataBase import UtilsDataBase from WorkUtils.UtilsDataBase import UtilsDataBase
from WorkUtils.UtilsResponse import UtilsResponse from WorkUtils.UtilsResponse import UtilsResponse
from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
from WorkData.Zabbix.hosts import DataHosts
from WorkData.Zabbix.items import DataItems
from WorkData.Zabbix.interface import DataInterface from WorkData.Zabbix.interface import DataInterface
import allure import allure
# allure.label("")
@allure.feature("测试模块:hostinterface.create") @allure.feature("测试模块:hostinterface.create")
class TestHostInterfaceCreate(object): class TestHostInterfaceCreate(object):
...@@ -29,9 +30,12 @@ class TestHostInterfaceCreate(object): ...@@ -29,9 +30,12 @@ class TestHostInterfaceCreate(object):
db_user = env["db_user"] db_user = env["db_user"]
db_pw = env["db_pw"] db_pw = env["db_pw"]
db_base = env["db_base"] db_base = env["db_base"]
base_host_name = "SS TEST HOST"
base_description = "SS TEST HOST-interface"
base_name = "SS测试主机接口" base_name = "SS测试主机接口"
base_ip = "10.0.0.28" base_ip = "10.0.0.28"
base_hostid = 10266
base_dns = "sanshi.zmops.cn" base_dns = "sanshi.zmops.cn"
base_port = "127" base_port = "127"
...@@ -39,7 +43,14 @@ class TestHostInterfaceCreate(object): ...@@ -39,7 +43,14 @@ class TestHostInterfaceCreate(object):
def setup_class(cls): def setup_class(cls):
cls.log.debug("开始执行测试套件.......") cls.log.debug("开始执行测试套件.......")
session = UtilsDataBase().conn_mysql(db_url=cls.db_url, db_port=cls.db_port, db_base=cls.db_base, db_user=cls.db_user, db_pw=cls.db_pw) session = UtilsDataBase().conn_mysql(db_url=cls.db_url, db_port=cls.db_port, db_base=cls.db_base, db_user=cls.db_user, db_pw=cls.db_pw)
DataInterface().delete_hostid(session=session, hostid=cls.base_hostid) sql = DataHosts().select_like_name(session=session, name=cls.base_host_name)
for x, y in enumerate(sql):
session = UtilsDataBase().conn_mysql(db_url=cls.db_url, db_port=cls.db_port, db_base=cls.db_base, db_user=cls.db_user, db_pw=cls.db_pw)
DataItems().delete_hostid(session=session, hostid=y.hostid)
session = UtilsDataBase().conn_mysql(db_url=cls.db_url, db_port=cls.db_port, db_base=cls.db_base, db_user=cls.db_user, db_pw=cls.db_pw)
DataHosts().delete_like_name(session=session, name=cls.base_host_name)
@classmethod @classmethod
def teardown_class(cls): def teardown_class(cls):
...@@ -116,62 +127,115 @@ class TestHostInterfaceCreate(object): ...@@ -116,62 +127,115 @@ class TestHostInterfaceCreate(object):
_status = UtilsResponse().get_status(response=response) _status = UtilsResponse().get_status(response=response)
assert _status == status assert _status == status
@allure.step("调用接口:host.create")
def host_create(self, host=None, name=None, description=None, groupids=None, interfaces=None, tags=None, templateids=None, macros=None,
inventory=None, status=None, inventory_mode=None):
api = HostCreate(_host=self.host)
api.host = host
api.name = name
api.description = description
api.groupids = groupids
api.interfaces = interfaces
api.tags = tags
api.templateids = templateids
api.macros = macros
api.inventory = inventory
api.status = status
api.inventory_mode = inventory_mode
api.tls_connect = 1
api.tls_accept = 1
api.tls_psk_identity = "Test"
api.tls_psk = "Test"
api.get_response()
return api.response
@allure.step("创建测试数据")
def case_create(self, num):
templateid = 10001
host = self.base_host_name + num
description = self.base_description + num
interfaces = {
"type": 2,
"main": 1,
"useip": 1,
"ip": self.base_ip,
"dns": "",
"port": 100,
"bulk": 1
}
response = self.host_create(host=host, description=description, groupids=[self.base_groupid],
interfaces=[interfaces], status=0, templateids=[templateid],
macros=[{
"macro": "{$SNMP_COMMUNITY}",
"value": "public"
}])
self.check_code(response=response, code=0)
self.hostid = UtilsResponse().get_result(response=response)["hostids"][0]
return self.hostid
@allure.title("hostinterface.create:IP地址相应信息") @allure.title("hostinterface.create:IP地址相应信息")
@allure.story("创建主机接口:IP地址相应信息") @allure.story("创建主机接口:IP地址相应信息")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_01(self): def test_case_01(self):
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=1, useip=1, bulk=1) self.case_create(num="01")
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=1, useip=1, bulk=1)
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0] interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0]
self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=1, useip=1, bulk=1) self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=1, useip=1, bulk=1)
@allure.title("hostinterface.create:DNS地址相应信息") @allure.title("hostinterface.create:DNS地址相应信息")
@allure.story("创建主机接口:DNS地址相应信息") @allure.story("创建主机接口:DNS地址相应信息")
def test_case_02(self): def test_case_02(self):
response = self.hostinterface_create(ip="", dns=self.base_dns, hostid=self.base_hostid, main=1, port=self.base_port, _type=2, useip=0, bulk=1) self.case_create(num="02")
response = self.hostinterface_create(ip="", dns=self.base_dns, hostid=self.hostid, main=1, port=self.base_port, _type=2, useip=0, bulk=1)
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0] interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0]
self.check_select(interfaceid=interfaceid, ip="", dns=self.base_dns, hostid=self.base_hostid, main=1, port=self.base_port, _type=2, useip=0, bulk=1) self.check_select(interfaceid=interfaceid, ip="", dns=self.base_dns, hostid=self.hostid, main=1, port=self.base_port, _type=2, useip=0, bulk=1)
@allure.title("hostinterface.create:默认接口重复添加") @allure.title("hostinterface.create:默认接口重复添加")
@allure.story("创建主机接口:默认接口重复添加") @allure.story("创建主机接口:默认接口重复添加")
def test_case_03(self): def test_case_03(self):
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=3, useip=1, bulk=1) self.case_create(num="03")
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=3, useip=1, bulk=1)
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0] interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0]
self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=3, useip=1, bulk=1) self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=3, useip=1, bulk=1)
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=3, useip=1, bulk=1) response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=3, useip=1, bulk=1)
self.check_code(response=response, code=100) self.check_code(response=response, code=100)
self.check_msg(response=response, msg="主机不能拥有多个同种类型的默认接口") self.check_msg(response=response, msg="主机不能拥有多个同种类型的默认接口")
@allure.title("hostinterface.create:此类型已有默认 可添加非默认接口") @allure.title("hostinterface.create:此类型已有默认 可添加非默认接口")
@allure.story("创建主机接口:此类型已有默认 可添加非默认接口") @allure.story("创建主机接口:此类型已有默认 可添加非默认接口")
def test_case_04(self): def test_case_04(self):
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=4, useip=1, bulk=1) self.case_create(num="04")
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=4, useip=1, bulk=1)
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0] interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0]
self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=4, useip=1, bulk=1) self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=4, useip=1, bulk=1)
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.base_hostid, main=0, port=self.base_port, _type=4, useip=1, bulk=1) response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.hostid, main=0, port=self.base_port, _type=4, useip=1, bulk=1)
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0] interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0]
self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.base_hostid, main=0, port=self.base_port, _type=4, useip=1, bulk=1) self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.hostid, main=0, port=self.base_port, _type=4, useip=1, bulk=1)
@allure.title("hostinterface.create:此类型未有默认 无法添加非默认接口") @allure.title("hostinterface.create:此类型未有默认 无法添加非默认接口")
@allure.story("创建主机接口:此类型未有默认 无法添加非默认接口") @allure.story("创建主机接口:此类型未有默认 无法添加非默认接口")
def test_case_05(self): def test_case_05(self):
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.base_hostid, main=0, port=self.base_port, _type=5, useip=1, bulk=1) self.case_create(num="05")
response = self.hostinterface_create(ip=self.base_ip, dns="", hostid=self.hostid, main=0, port=self.base_port, _type=5, useip=1, bulk=1)
self.check_code(response=response, code=100) self.check_code(response=response, code=100)
self.check_msg(response=response, msg="主机11的类型[Unknown interface type]没有默认接口") self.check_msg(response=response, msg="主机11的类型[Unknown interface type]没有默认接口")
@allure.title("hostinterface.create:useip=0, bulk=1") @allure.title("hostinterface.create:useip=0, bulk=1")
@allure.story("创建主机接口:useip=0, bulk=1") @allure.story("创建主机接口:useip=0, bulk=1")
def test_case_06(self): def test_case_06(self):
response = self.hostinterface_create(ip=self.base_ip, dns=self.base_dns, hostid=self.base_hostid, main=1, port=self.base_port, _type=6, useip=0, bulk=1) self.case_create(num="06")
response = self.hostinterface_create(ip=self.base_ip, dns=self.base_dns, hostid=self.hostid, main=1, port=self.base_port, _type=6, useip=0, bulk=1)
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0] interfaceid = UtilsResponse().get_result(response=response)["interfaceids"][0]
self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.base_hostid, main=1, port=self.base_port, _type=6, useip=0, bulk=1) self.check_select(interfaceid=interfaceid, ip=self.base_ip, dns="", hostid=self.hostid, main=1, port=self.base_port, _type=6, useip=0, bulk=1)
if __name__ == "__main__": if __name__ == "__main__":
......
# -*- coding: utf-8 -*-
# 测试用例
# 作者: 陈磊
# 时间: 2019-11-28
from __future__ import division
from WorkCase import CaseBase
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.alarm_rule import DataAlarmRule
import allure
@allure.feature("测试模块:device.create")
class TestDeviceCreate(object):
log = UtilsLog()
env = CaseBase().app_environment
host = "http://172.16.3.78:3334"
db_url = env["db_url"]
db_port = env["db_port"]
db_user = env["db_user"]
db_pw = env["db_pw"]
db_base = env["db_base"]
login_name = "SS测试用户名"
base_id = 10
base_password = "123456"
base_type_agent = 126
base_type_snmp = 127
base_ip = "172.16.3.170"
base_dns = "sanshi.zmops.com"
base_port = 999
base_name = "SS测试资产"
@classmethod
def setup_class(cls):
cls.log.debug("开始执行测试套件.......")
@classmethod
def teardown_class(cls):
cls.log.debug("结束执行测试套件.......")
def setup_method(self):
self.log.debug("测试用例执行开始...")
self.update_members_del_flag(members_id=self.base_id, value=0)
self.update_members_status(members_id=self.base_id, value=0)
def teardown_method(self):
self.log.debug("测试用例执行结束...")
self.update_members_del_flag(members_id=self.base_id, value=0)
self.update_members_status(members_id=self.base_id, value=0)
@allure.step("调用接口:api.login")
def api_login(self, name=None, password=None):
api = ApiLogin(_host=self.host)
api.name = name
api.password = password
api.get_response()
return api.response
@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
@allure.step("调用接口:device.create")
def device_create(self, token=None, hostName=None, hostType=None, iplist=None, dns=None,
monitorInterface=None, monitorType=None,
parentHost=None, businessIds=None, opsPerson=None, snmpCommunity=None, ipmiAuthtype=None,
ipmiPrivilege=None, ipmiUsername=None, ipmiPassword=None,
factory=None, model=None, version=None, serialnumber=None,
description=None, monitorStatus=None):
api = DeviceCreate(_host=self.host)
api.token = token
api.hostName = hostName
api.hostType = hostType
api.iplist = iplist
api.dns = dns
api.monitorInterface = monitorInterface
api.monitorType = monitorType
api.parentHost = parentHost
api.businessIds = businessIds
api.opsPerson = opsPerson
api.snmpCommunity = snmpCommunity
api.ipmiAuthtype = ipmiAuthtype
api.ipmiPrivilege = ipmiPrivilege
api.ipmiUsername = ipmiUsername
api.ipmiPassword = ipmiPassword
api.factory = factory
api.model = model
api.version = version
api.serialnumber = serialnumber
api.description = description
api.monitorStatus = monitorStatus
api.get_response()
return api.response
@allure.step("获取token")
def get_base_token(self):
response = self.api_login(name=self.login_name, password=self.base_password)
self.token = UtilsResponse().get_data(response=response)
@allure.step("连接数据库:Argus")
def db_session(self):
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("查询表:alarm_rule")
def select_alarm_rule(self, alarm_ruleid=None, name=None, triggerid=None):
session = self.db_session()
sql = DataAlarmRule().select_all_from_allKeys(session=session, alarm_ruleid=alarm_ruleid, name=name, triggerid=triggerid)
return sql
@allure.step("校验查询结果")
def check_select(self, response, name, description, _type, principal_name, principal_phone, memberid):
data = UtilsResponse().get_data(response=response)
sql = self.select_businesses(businessid=data)
for x, y in enumerate(sql):
assert y.name == name
assert y.description == description
assert y.type == _type
assert y.principal_name == principal_name
assert y.principal_phone == principal_phone
assert y.memberid == memberid
assert x == 0
@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):
self.get_base_token()
response = self.device_create()
self.check_code(response=response, code=2001)
self.check_msg(response=response, msg="无token,请重新登录")
@allure.title("device.create:token的用户已删除")
@allure.story("创建资产:token的用户已删除")
@allure.severity("blocker")
def test_case_02(self):
self.get_base_token()
self.update_members_del_flag(members_id=self.base_id, value=1)
response = self.device_create(token=self.token)
self.check_code(response=response, code=2004)
self.check_msg(response=response, msg="用户不存在")
@allure.title("device.create:token的用户已禁用")
@allure.story("创建资产:token的用户已禁用")
@allure.severity("blocker")
def test_case_03(self):
self.get_base_token()
self.update_members_status(members_id=self.base_id, value=1)
response = self.device_create(token=self.token)
self.check_code(response=response, code=2003)
self.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.create:创建agent资产,ip识别")
@allure.story("创建资产:创建agent资产,ip识别")
@allure.severity("blocker")
def test_case_04(self):
self.get_base_token()
name = self.base_name + "04"
response = self.device_create(token=self.token, hostName=name, hostType=self.base_type_agent, iplist=self.base_ip, monitorInterface=self.base_port,
monitorType=1)
self.check_code(response=response, code=0)
@allure.title("device.create:创建agent设备在线规则")
@allure.story("创建资产:创建agent设备在线规则")
def test_case_05(self):
self.get_base_token()
name = self.base_name + "05"
response = self.device_create(token=self.token, name=name, severity=0, status=1, manualClose=1, triggersList_hostid=[10466],
triggersList_hostName=["SS TEST HOST04"], triggersList_itemid=[39676],
triggersList_itemName=["agent.ping"], triggersList_function=["avg"],
triggersList_operator=["="], triggersList_constant=[888],
triggersList_parameters_unit=["m"], triggersList_parameters_value=[5], triggersList_onlineFlag=[True])
self.check_code(response=response, code=0)
@allure.title("device.create:创建agent设备离线规则")
@allure.story("创建资产:创建agent设备离线规则")
def test_case_06(self):
self.get_base_token()
name = self.base_name + "06"
response = self.device_create(token=self.token, name=name, severity=0, status=1, manualClose=1, triggersList_hostid=[10466],
triggersList_hostName=["SS TEST HOST04"], triggersList_itemid=[39676],
triggersList_itemName=["agent.ping]"], triggersList_function=["avg"],
triggersList_operator=["="], triggersList_constant=[888],
triggersList_parameters_unit=["m"], triggersList_parameters_value=[5], triggersList_onlineFlag=[False])
self.check_code(response=response, code=0)
@allure.title("device.create:创建icmp设备在线规则")
@allure.story("创建资产:创建icmp设备在线规则")
def test_case_07(self):
self.get_base_token()
name = self.base_name + "07"
response = self.device_create(token=self.token, name=name, severity=0, status=1, manualClose=1, triggersList_hostid=[10466],
triggersList_hostName=["SS TEST HOST04"], triggersList_itemid=[39676],
triggersList_itemName=["agent.ping]"], triggersList_function=["avg"],
triggersList_operator=["="], triggersList_constant=[888],
triggersList_parameters_unit=["m"], triggersList_parameters_value=[5], triggersList_onlineFlag=[True])
self.check_code(response=response, code=0)
@allure.title("device.create:创建icmp设备离线规则")
@allure.story("创建资产:创建icmp设备离线规则")
def test_case_08(self):
self.get_base_token()
name = self.base_name + "08"
response = self.device_create(token=self.token, name=name, severity=0, status=1, manualClose=1, triggersList_hostid=[10466],
triggersList_hostName=["SS TEST HOST04"], triggersList_itemid=[39676],
triggersList_itemName=["agent.ping]"], triggersList_function=["avg"],
triggersList_operator=["="], triggersList_constant=[888],
triggersList_parameters_unit=["m"], triggersList_parameters_value=[5], triggersList_onlineFlag=[True])
self.check_code(response=response, code=0)
if __name__ == "__main__":
from WorkUtils.UtilsPyTest import UtilsPyTest
from WorkUtils.UtilsCmd import UtilsCmd
import os
# 执行自动化测试用例
# case_info = os.path.split(__file__)
# case = UtilsCmd().pytest_cmd()
# r = UtilsPyTest(case=case, case_info=case_info)
# r.run_main()
a = TestDeviceCreate()
a.setup_class()
a.test_case_04()
...@@ -215,7 +215,7 @@ class TestRuleCreate(object): ...@@ -215,7 +215,7 @@ class TestRuleCreate(object):
triggersList_hostName=["SS TEST HOST04"], triggersList_itemid=[39676], triggersList_hostName=["SS TEST HOST04"], triggersList_itemid=[39676],
triggersList_itemName=["agent.ping]"], triggersList_function=["avg"], triggersList_itemName=["agent.ping]"], triggersList_function=["avg"],
triggersList_operator=["="], triggersList_constant=[888], triggersList_operator=["="], triggersList_constant=[888],
triggersList_parameters_unit=["m"], triggersList_parameters_value=[5], triggersList_onlineFlag=[True]) triggersList_parameters_unit=["m"], triggersList_parameters_value=[5], triggersList_onlineFlag=[False])
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
@allure.title("rule.create:创建icmp设备在线规则") @allure.title("rule.create:创建icmp设备在线规则")
...@@ -260,4 +260,4 @@ if __name__ == "__main__": ...@@ -260,4 +260,4 @@ if __name__ == "__main__":
a = TestRuleCreate() a = TestRuleCreate()
a.setup_class() a.setup_class()
a.test_case_05() a.test_case_06()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment