Commit 08cf0ec7 by sanshi

资产模块

parent 94585e9c
......@@ -98,9 +98,9 @@ class TestDeviceGet(object):
self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, name=self.base_name + "05")
response = self.app.device_get(token=self.token, name=name)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="name", _value=self.base_name + "05")
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="name", _value=name)
@allure.title("device.get:type查询")
@allure.story("查询资产:type查询")
......@@ -111,7 +111,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, _type=self.base_type_snmp)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="hostType", _value=self.base_type_snmp)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="hostType", _value=self.base_type_snmp)
@allure.title("device.get:manageLevel查询")
@allure.story("查询资产:manageLevel查询")
......@@ -122,7 +122,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, manageLevel=1)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="manageLevel", _value=1)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="manageLevel", _value=1)
@allure.title("device.get:monitorStatus查询")
@allure.story("查询资产:monitorStatus查询")
......@@ -133,7 +133,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, monitorStatus=1)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="monitorStatus", _value=1)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="monitorStatus", _value=1)
@allure.title("device.get:available查询")
@allure.story("查询资产:available查询")
......@@ -144,7 +144,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, available=1)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="available", _value=1)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="available", _value=1)
@allure.title("device.get:businessIds查询")
@allure.story("查询资产:businessIds查询")
......@@ -153,9 +153,10 @@ class TestDeviceGet(object):
self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, businessIds=self.base_business_id_1)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="businessesNames", _value=self.base_business_name_1 + "," + self.base_business_name_2)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="businessesNames",
_value=self.base_business_name_1 + "," + self.base_business_name_2)
@allure.title("device.get:memberId查询")
@allure.story("查询资产:memberId查询")
......@@ -166,7 +167,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, memberId=11)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="memberName", _value="sanshi")
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="memberName", _value="sanshi")
@allure.title("device.get:factoryId查询")
@allure.story("查询资产:factoryId查询")
......@@ -177,7 +178,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, factoryId=1)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="factoryId", _value=1)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="factoryId", _value=1)
@allure.title("device.get:manageIp查询")
@allure.story("查询资产:manageIp查询")
......@@ -188,7 +189,7 @@ class TestDeviceGet(object):
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_get(token=self.token, manageIp=self.base_ip)
self.app.check_code(response=response, code=0)
self.app.check_keyValue(response=UtilsResponse().get_data(response=response), _key="manageIp", _value=self.base_ip)
self.app.check_keyValue(_json=UtilsResponse().get_data_list(response=response), _key="manageIp", _value=self.base_ip)
@allure.title("device.get:menuId查询")
@allure.story("查询资产:menuId查询")
......@@ -211,4 +212,5 @@ if __name__ == "__main__":
# a = TestDeviceGet()
# a.setup_class()
# a.test_case_14()
# a.setup_method()
# a.test_case_07()
......@@ -7,6 +7,7 @@
from __future__ import division
from WorkCase import CaseBase
from WorkData.Argus.businesses_hosts import DataBusinessesHosts
from WorkData.Zabbix.interface import DataInterface
from WorkUtils.UtilsLog import UtilsLog
from WorkUtils.UtilsDataBase import UtilsDataBase
......@@ -114,6 +115,12 @@ class TestDeviceUpdate(object):
sql = DataInterface().select_all_from_allKeys(session=session, hostid=hostid)
return sql
@allure.step("查询表:businesses_hosts")
def select_businesses_hosts(self, hostid=None, businessesid=None):
session = self.db_session()
sql = DataBusinessesHosts().select_all_from_allKeys(session=session, hostid=hostid, businessesid=businessesid)
return sql
@allure.step("校验Zabbix接口数据")
def check_interface(self, host_id, _type, useip, ip, dns, port):
sql = self.select_interface(hostid=host_id)
......@@ -131,7 +138,7 @@ class TestDeviceUpdate(object):
def check_select(self, response, name, manage_ip, manage_level, host_type, parent_host,
monitor_type, monitor_status, iplist, dns, monitor_interface, ops_person, factoryId,
model, version, serialnumber, description, snmp_community, ipmi_authtype, ipmi_privilege,
ipmi_username, ipmi_password, businessIds, hostTypeTree, businessTree):
ipmi_username, ipmi_password, hostTypeTree, businessTree):
data = UtilsResponse().get_data(response=response)
sql = self.select_hosts(hostid=data)
assert sql != []
......@@ -149,7 +156,6 @@ class TestDeviceUpdate(object):
assert y.iplist == iplist
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
......@@ -166,15 +172,23 @@ class TestDeviceUpdate(object):
assert y.ipmi_password == ipmi_password
assert x == 0
sql = self.select_businesses_hosts(hostid=data)
business_ids = []
for x, y in enumerate(sql):
assert y.businessesid in [self.base_business_id_1, self.base_business_id_2]
business_ids.append(y.businessesid)
for x, y in enumerate([self.base_business_id_1, self.base_business_id_2]):
assert y in business_ids
@allure.title("device.update:更新所有字段")
@allure.story("更新资产:更新所有字段")
@allure.severity("blocker")
def test_case_01(self):
name = self.base_name + "01"
host_id = self.app.case_create_host(name=name, host_type=self.base_type_agent,
host_id = self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2])
response = self.app.device_update(token=self.token, hostid=host_id, hostName=name + "修改",
businessIds=[self.base_business_id_1])
response = self.app.device_update(token=self.token, hostid=host_id, hostName=name + "修改", hostType=self.base_type_snmp,
dns=self.base_update_dns, monitorInterface=self.base_update_port,
monitorType=2, manageLevel=1, parentHost=1,
businessIds=[self.base_business_id_1, self.base_business_id_2],
......@@ -185,33 +199,13 @@ class TestDeviceUpdate(object):
monitorStatus=0)
self.app.check_code(response=response, code=0)
self.check_select(response=response, name=name + "修改", manage_ip=self.base_update_dns, manage_level=1,
host_type=self.base_type_agent, monitor_type=2, monitor_status=0,
host_type=self.base_type_snmp, monitor_type=2, monitor_status=0,
iplist="", dns=self.base_update_dns, monitor_interface=self.base_update_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], hostTypeTree="hostTypeTree", businessTree="businessTree")
self.check_interface(host_id=host_id, _type=1, useip=0, ip="", dns=self.base_update_dns, port=self.base_update_port)
response = self.app.device_update(token=self.token, hostid=host_id, hostName=name + "修改1",
iplist=self.base_ip, monitorInterface=self.base_port,
monitorType=1, manageLevel=2, parentHost=1,
businessIds=[self.base_business_id_1, self.base_business_id_2], hostTypeTree="hostTypeTree1", businessTree="businessTree1",
opsPerson=11, snmpCommunity="snmpCommunity1",
ipmiAuthtype=1, ipmiPrivilege=1, ipmiUsername="ipmiUsername1", ipmiPassword="ipmiPassword1",
factoryId=1, model="1model", version="1version", serialnumber="1serialnumber", description="1description",
monitorStatus=0)
self.app.check_code(response=response, code=0)
self.check_select(response=response, name=name + "修改1", manage_ip=self.base_ip, manage_level=2,
host_type=self.base_type_agent, monitor_type=1, monitor_status=0,
iplist=self.base_ip, dns="", monitor_interface=self.base_port,
ops_person=11, snmp_community="snmpCommunity1",
ipmi_authtype=1, ipmi_privilege=1, ipmi_username="ipmiUsername1", ipmi_password="ipmiPassword1", parent_host=1,
factoryId=1, model="1model", version="1version", serialnumber="1serialnumber", description="1description",
businessIds=[self.base_business_id_1, self.base_business_id_2],
hostTypeTree="hostTypeTree1", businessTree="businessTree1", )
self.check_interface(host_id=host_id, _type=1, useip=1, ip=self.base_ip, dns="", port=self.base_port)
hostTypeTree="hostTypeTree", businessTree="businessTree")
self.check_interface(host_id=host_id, _type=2, useip=0, ip="", dns=self.base_update_dns, port=self.base_update_port)
if __name__ == "__main__":
......@@ -229,4 +223,4 @@ if __name__ == "__main__":
# a = TestDeviceUpdate()
# a.setup_class()
# a.setup_method()
# a.test_case_04()
# a.test_case_01()
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