Commit 94585e9c by sanshi

资产

parent 96fc1441
...@@ -59,10 +59,10 @@ class TestProblemAcknowledge(object): ...@@ -59,10 +59,10 @@ class TestProblemAcknowledge(object):
DataHosts().delete_like_name(session=session, name=cls.base_host_name) DataHosts().delete_like_name(session=session, name=cls.base_host_name)
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)
DataEvents().delete_like_name(session=session, name=cls.base_name) DataEvents().delete_like_eventid(session=session, eventid=cls.base_eventid)
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)
DataProblem().delete_like_name(session=session, name=cls.base_name) DataProblem().delete_like_eventid(session=session, eventid=cls.base_eventid)
@classmethod @classmethod
def teardown_class(cls): def teardown_class(cls):
...@@ -78,7 +78,10 @@ class TestProblemAcknowledge(object): ...@@ -78,7 +78,10 @@ class TestProblemAcknowledge(object):
DataHosts().delete_like_name(session=session, name=cls.base_host_name) DataHosts().delete_like_name(session=session, name=cls.base_host_name)
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)
DataEvents().delete_like_name(session=session, name=cls.base_name) DataEvents().delete_like_eventid(session=session, eventid=cls.base_eventid)
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)
DataEvents().delete_like_eventid(session=session, eventid=cls.base_eventid)
def setup_method(self): def setup_method(self):
self.log.debug("测试用例执行开始...") self.log.debug("测试用例执行开始...")
......
...@@ -27,7 +27,7 @@ import allure ...@@ -27,7 +27,7 @@ import allure
@allure.feature("测试模块:device.asset.getFactoryList") @allure.feature("测试模块:device.asset.getFactoryList")
class TestDeviceAssetGetFactoryList(object): class TestDeviceAssetGetFactoryList(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
...@@ -84,46 +84,17 @@ class TestDeviceAssetGetFactoryList(object): ...@@ -84,46 +84,17 @@ class TestDeviceAssetGetFactoryList(object):
sql = DataHosts().select_all_from_allKeys(session=session, hostid=hostid, host_name=host_name, available=available, monitor_status=monitor_status) sql = DataHosts().select_all_from_allKeys(session=session, hostid=hostid, host_name=host_name, available=available, monitor_status=monitor_status)
return sql return sql
@allure.title("device.asset.getFactoryList:token未传")
@allure.story("查询品牌下拉框:token未传")
@allure.severity("blocker")
@pytest.mark.skip(reason="此接口未加入token验证")
def test_case_01(self):
response = self.app.device_asset_getFactoryList()
self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在")
@allure.title("device.asset.getFactoryList:token的用户已删除")
@allure.story("查询品牌下拉框:token的用户已删除")
@allure.severity("blocker")
@pytest.mark.skip(reason="此接口未加入token验证")
def test_case_02(self):
self.app.update_members_del_flag(members_id=self.base_id, value=CaseBase().del_flag["ON"])
response = self.app.device_asset_getFactoryList(token=self.token)
self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在")
@allure.title("device.asset.getFactoryList:token的用户已禁用")
@allure.story("查询品牌下拉框:token的用户已禁用")
@allure.severity("blocker")
@pytest.mark.skip(reason="此接口未加入token验证")
def test_case_03(self):
self.app.update_members_status(members_id=self.base_id, value=CaseBase().status["OFF"])
response = self.app.device_asset_getFactoryList(token=self.token)
self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.asset.getFactoryList:无参数调用") @allure.title("device.asset.getFactoryList:无参数调用")
@allure.story("查询品牌下拉框:无参数调用") @allure.story("查询品牌下拉框:无参数调用")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
response = self.app.device_asset_getFactoryList(token=self.token) response = self.app.device_asset_getFactoryList(token=self.token)
self.app.check_code(response=response, code=0) self.app.check_code(response=response, code=0)
@allure.title("device.asset.getFactoryList:hostType查询") @allure.title("device.asset.getFactoryList:hostType查询")
@allure.story("查询品牌下拉框:hostType查询") @allure.story("查询品牌下拉框:hostType查询")
def test_case_05(self): def test_case_02(self):
name = self.base_name + "05" name = self.base_name + "02"
self.app.case_create_host(name=name, host_type=self.base_type_agent, self.app.case_create_host(name=name, host_type=self.base_type_agent,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -135,8 +106,8 @@ class TestDeviceAssetGetFactoryList(object): ...@@ -135,8 +106,8 @@ class TestDeviceAssetGetFactoryList(object):
@allure.title("device.asset.getFactoryList:hostType查询") @allure.title("device.asset.getFactoryList:hostType查询")
@allure.story("查询品牌下拉框:hostType查询") @allure.story("查询品牌下拉框:hostType查询")
def test_case_06(self): def test_case_03(self):
name = self.base_name + "06" name = self.base_name + "03"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
......
...@@ -27,7 +27,7 @@ import allure ...@@ -27,7 +27,7 @@ import allure
@allure.feature("测试模块:device.asset.ips") @allure.feature("测试模块:device.asset.ips")
class TestDeviceAssetIps(object): class TestDeviceAssetIps(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
...@@ -95,46 +95,17 @@ class TestDeviceAssetIps(object): ...@@ -95,46 +95,17 @@ class TestDeviceAssetIps(object):
self.check_code(response=response, code=0) self.check_code(response=response, code=0)
self.device_id = UtilsResponse().get_data(response=response) self.device_id = UtilsResponse().get_data(response=response)
@allure.title("device.asset.ips:token未传")
@allure.story("查询资产IPS下拉框:token未传")
@allure.severity("blocker")
@pytest.mark.skip(reason="此接口未加入token验证")
def test_case_01(self):
response = self.app.device_asset_ips()
self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在")
@allure.title("device.asset.ips:token的用户已删除")
@allure.story("查询资产IPS下拉框:token的用户已删除")
@allure.severity("blocker")
@pytest.mark.skip(reason="此接口未加入token验证")
def test_case_02(self):
self.app.update_members_del_flag(members_id=self.base_id, value=CaseBase().del_flag["ON"])
response = self.app.device_asset_ips(token=self.token)
self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在")
@allure.title("device.asset.ips:token的用户已禁用")
@allure.story("查询资产IPS下拉框:token的用户已禁用")
@allure.severity("blocker")
@pytest.mark.skip(reason="此接口未加入token验证")
def test_case_03(self):
self.app.update_members_status(members_id=self.base_id, value=CaseBase().status["OFF"])
response = self.app.device_asset_ips(token=self.token)
self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.asset.ips:无参数调用") @allure.title("device.asset.ips:无参数调用")
@allure.story("查询资产IPS下拉框:无参数调用") @allure.story("查询资产IPS下拉框:无参数调用")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
response = self.app.device_asset_ips(token=self.token) response = self.app.device_asset_ips(token=self.token)
self.app.check_code(response=response, code=0) self.app.check_code(response=response, code=0)
@allure.title("device.asset.ips:ipName查询") @allure.title("device.asset.ips:ipName查询")
@allure.story("查询资产IPS下拉框:ipName查询") @allure.story("查询资产IPS下拉框:ipName查询")
def test_case_05(self): def test_case_01(self):
name = self.base_name + "05" name = self.base_name + "01"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
......
...@@ -25,7 +25,7 @@ from WorkCase.APP import AppBase ...@@ -25,7 +25,7 @@ from WorkCase.APP import AppBase
@allure.feature("测试模块:device.create") @allure.feature("测试模块:device.create")
class TestDeviceCreate(object): class TestDeviceCreate(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
...@@ -174,7 +174,7 @@ class TestDeviceCreate(object): ...@@ -174,7 +174,7 @@ class TestDeviceCreate(object):
business_ids = [] business_ids = []
for x, y in enumerate(sql): for x, y in enumerate(sql):
assert y.businessesid in [self.base_business_id_1, self.base_business_id_2] assert y.businessesid in [self.base_business_id_1, self.base_business_id_2]
business_ids.append(y.business_ids) business_ids.append(y.businessesid)
for x, y in enumerate([self.base_business_id_1, self.base_business_id_2]): for x, y in enumerate([self.base_business_id_1, self.base_business_id_2]):
assert y in business_ids assert y in business_ids
...@@ -187,37 +187,11 @@ class TestDeviceCreate(object): ...@@ -187,37 +187,11 @@ class TestDeviceCreate(object):
assert y.host_name == name assert y.host_name == name
assert y.monitor_type == monitor_type assert y.monitor_type == monitor_type
@allure.title("device.create:token未传")
@allure.story("创建资产:token未传")
@allure.severity("blocker")
def test_case_01(self):
response = self.app.device_create()
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.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.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.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.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.create:创建agent资产,ip识别") @allure.title("device.create:创建agent资产,ip识别")
@allure.story("创建资产:创建agent资产,ip识别") @allure.story("创建资产:创建agent资产,ip识别")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
name = self.base_name + "04" name = self.base_name + "01"
response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_agent, response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_agent,
iplist=self.base_ip, monitorInterface=self.base_port, iplist=self.base_ip, monitorInterface=self.base_port,
monitorType=1, manageLevel=1) monitorType=1, manageLevel=1)
...@@ -229,8 +203,8 @@ class TestDeviceCreate(object): ...@@ -229,8 +203,8 @@ class TestDeviceCreate(object):
@allure.title("device.create:创建agent资产,dns识别") @allure.title("device.create:创建agent资产,dns识别")
@allure.story("创建资产:创建agent资产,dns识别") @allure.story("创建资产:创建agent资产,dns识别")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_05(self): def test_case_02(self):
name = self.base_name + "05" name = self.base_name + "02"
response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_agent, response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_agent,
dns=self.base_dns, dns=self.base_dns,
monitorInterface=self.base_port, monitorType=2, manageLevel=1) monitorInterface=self.base_port, monitorType=2, manageLevel=1)
...@@ -242,8 +216,8 @@ class TestDeviceCreate(object): ...@@ -242,8 +216,8 @@ class TestDeviceCreate(object):
@allure.title("device.create:创建snmp资产,ip识别") @allure.title("device.create:创建snmp资产,ip识别")
@allure.story("创建资产:创建snmp资产,ip识别") @allure.story("创建资产:创建snmp资产,ip识别")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_06(self): def test_case_03(self):
name = self.base_name + "06" name = self.base_name + "03"
response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_snmp, response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_snmp,
iplist=self.base_ip, monitorInterface=self.base_port, iplist=self.base_ip, monitorInterface=self.base_port,
monitorType=1, manageLevel=1) monitorType=1, manageLevel=1)
...@@ -255,8 +229,8 @@ class TestDeviceCreate(object): ...@@ -255,8 +229,8 @@ class TestDeviceCreate(object):
@allure.title("device.create:创建snmp资产,dns识别") @allure.title("device.create:创建snmp资产,dns识别")
@allure.story("创建资产:创建snmp资产,dns识别") @allure.story("创建资产:创建snmp资产,dns识别")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_07(self): def test_case_04(self):
name = self.base_name + "07" name = self.base_name + "04"
response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_snmp, response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_snmp,
dns=self.base_dns, dns=self.base_dns,
monitorInterface=self.base_port, monitorType=2, manageLevel=1) monitorInterface=self.base_port, monitorType=2, manageLevel=1)
...@@ -267,8 +241,8 @@ class TestDeviceCreate(object): ...@@ -267,8 +241,8 @@ class TestDeviceCreate(object):
@allure.title("device.create:创建资产-所有字段") @allure.title("device.create:创建资产-所有字段")
@allure.story("创建资产:创建资产-所有字段") @allure.story("创建资产:创建资产-所有字段")
def test_case_08(self): def test_case_05(self):
name = self.base_name + "08" name = self.base_name + "05"
response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_agent, response = self.app.device_create(token=self.token, hostName=name, hostType=self.base_type_agent,
iplist=self.base_ip, monitorInterface=self.base_port, iplist=self.base_ip, monitorInterface=self.base_port,
monitorType=1, manageLevel=1, parentHost=1, monitorType=1, manageLevel=1, parentHost=1,
...@@ -295,12 +269,12 @@ if __name__ == "__main__": ...@@ -295,12 +269,12 @@ if __name__ == "__main__":
import os import os
# 执行自动化测试用例 # 执行自动化测试用例
# case_info = os.path.split(__file__) case_info = os.path.split(__file__)
# case = UtilsCmd().pytest_cmd() case = UtilsCmd().pytest_cmd()
# r = UtilsPyTest(case=case, case_info=case_info) r = UtilsPyTest(case=case, case_info=case_info)
# r.run_main() r.run_main()
a = TestDeviceCreate() # a = TestDeviceCreate()
a.setup_class() # a.setup_class()
a.setup_method() # a.setup_method()
a.test_case_08() # a.test_case_08()
...@@ -27,13 +27,19 @@ from WorkCase.APP import AppBase ...@@ -27,13 +27,19 @@ from WorkCase.APP import AppBase
@allure.feature("测试模块:device.delete") @allure.feature("测试模块:device.delete")
class TestDeviceDelete(object): class TestDeviceDelete(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
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"]
host_zabbix = env["host_zabbix"]
db_url_zabbix = env["db_url_zabbix"]
db_port_zabbix = env["db_port_zabbix"]
db_user_zabbix = env["db_user_zabbix"]
db_pw_zabbix = env["db_pw_zabbix"]
db_base_zabbix = env["db_base_zabbix"] db_base_zabbix = env["db_base_zabbix"]
login_name = "SS测试用户名" login_name = "SS测试用户名"
...@@ -81,7 +87,8 @@ class TestDeviceDelete(object): ...@@ -81,7 +87,8 @@ class TestDeviceDelete(object):
@allure.step("连接数据库:Zabbix") @allure.step("连接数据库:Zabbix")
def db_session_zabbix(self): 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) session = UtilsDataBase().conn_mysql(db_url=self.db_url_zabbix, db_port=self.db_port_zabbix, db_base=self.db_base_zabbix,
db_user=self.db_user_zabbix, db_pw=self.db_pw_zabbix)
return session return session
@allure.step("查询表:hosts") @allure.step("查询表:hosts")
...@@ -106,37 +113,11 @@ class TestDeviceDelete(object): ...@@ -106,37 +113,11 @@ class TestDeviceDelete(object):
sql = self.select_hosts_zabbix(hostid=device_id) sql = self.select_hosts_zabbix(hostid=device_id)
assert sql == [] assert sql == []
@allure.title("device.delete:token未传")
@allure.story("删除资产:token未传")
@allure.severity("blocker")
def test_case_01(self):
response = self.app.device_delete()
self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在")
@allure.title("device.delete:token的用户已删除")
@allure.story("删除资产:token的用户已删除")
@allure.severity("blocker")
def test_case_02(self):
self.app.update_members_del_flag(session=self.db_session(), members_id=self.base_id, value=CaseBase().del_flag["ON"])
response = self.app.device_delete(token=self.token)
self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在")
@allure.title("device.delete:token的用户已禁用")
@allure.story("删除资产:token的用户已禁用")
@allure.severity("blocker")
def test_case_03(self):
self.app.update_members_status(session=self.db_session(), members_id=self.base_id, value=CaseBase().status["OFF"])
response = self.app.device_delete(token=self.token)
self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.delete:删除一个") @allure.title("device.delete:删除一个")
@allure.story("删除资产:删除一个") @allure.story("删除资产:删除一个")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
name = self.base_name + "04" name = self.base_name + "01"
host_id_1 = self.app.case_create_host(name=name, host_type=self.base_type_snmp, host_id_1 = self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -147,10 +128,10 @@ class TestDeviceDelete(object): ...@@ -147,10 +128,10 @@ class TestDeviceDelete(object):
@allure.title("device.delete:删除多个") @allure.title("device.delete:删除多个")
@allure.story("删除资产:删除多个") @allure.story("删除资产:删除多个")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_05(self): def test_case_02(self):
name_1 = self.base_name + "051" name_1 = self.base_name + "021"
name_2 = self.base_name + "052" name_2 = self.base_name + "022"
name_3 = self.base_name + "053" name_3 = self.base_name + "023"
host_id_1 = self.app.case_create_host(name=name_1, host_type=self.base_type_snmp, host_id_1 = self.app.case_create_host(name=name_1, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
......
...@@ -26,7 +26,7 @@ from WorkCase.APP import AppBase ...@@ -26,7 +26,7 @@ from WorkCase.APP import AppBase
@allure.feature("测试模块:device.get") @allure.feature("测试模块:device.get")
class TestDeviceGet(object): class TestDeviceGet(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
...@@ -84,43 +84,17 @@ class TestDeviceGet(object): ...@@ -84,43 +84,17 @@ class TestDeviceGet(object):
sql = DataHosts().select_all_from_allKeys(session=session, hostid=hostid, host_name=host_name, available=available, monitor_status=monitor_status) sql = DataHosts().select_all_from_allKeys(session=session, hostid=hostid, host_name=host_name, available=available, monitor_status=monitor_status)
return sql return sql
@allure.title("device.get:token未传")
@allure.story("查询资产:token未传")
@allure.severity("blocker")
def test_case_01(self):
response = self.app.device_get()
self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在")
@allure.title("device.get:token的用户已删除")
@allure.story("查询资产:token的用户已删除")
@allure.severity("blocker")
def test_case_02(self):
self.app.update_members_del_flag(session=self.db_session(), members_id=self.base_id, value=CaseBase().del_flag["ON"])
response = self.app.device_get(token=self.token)
self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在")
@allure.title("device.get:token的用户已禁用")
@allure.story("查询资产:token的用户已禁用")
@allure.severity("blocker")
def test_case_03(self):
self.app.update_members_status(session=self.db_session(), members_id=self.base_id, value=CaseBase().status["OFF"])
response = self.app.device_get(token=self.token)
self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.get:无参数调用") @allure.title("device.get:无参数调用")
@allure.story("查询资产:无参数调用") @allure.story("查询资产:无参数调用")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
response = self.app.device_get(token=self.token) response = self.app.device_get(token=self.token)
self.app.check_code(response=response, code=0) self.app.check_code(response=response, code=0)
@allure.title("device.get:name查询") @allure.title("device.get:name查询")
@allure.story("查询资产:name查询") @allure.story("查询资产:name查询")
def test_case_05(self): def test_case_02(self):
name = self.base_name + "05" name = self.base_name + "02"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -130,8 +104,8 @@ class TestDeviceGet(object): ...@@ -130,8 +104,8 @@ class TestDeviceGet(object):
@allure.title("device.get:type查询") @allure.title("device.get:type查询")
@allure.story("查询资产:type查询") @allure.story("查询资产:type查询")
def test_case_06(self): def test_case_03(self):
name = self.base_name + "06" name = self.base_name + "03"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -141,8 +115,8 @@ class TestDeviceGet(object): ...@@ -141,8 +115,8 @@ class TestDeviceGet(object):
@allure.title("device.get:manageLevel查询") @allure.title("device.get:manageLevel查询")
@allure.story("查询资产:manageLevel查询") @allure.story("查询资产:manageLevel查询")
def test_case_07(self): def test_case_04(self):
name = self.base_name + "07" name = self.base_name + "04"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -152,8 +126,8 @@ class TestDeviceGet(object): ...@@ -152,8 +126,8 @@ class TestDeviceGet(object):
@allure.title("device.get:monitorStatus查询") @allure.title("device.get:monitorStatus查询")
@allure.story("查询资产:monitorStatus查询") @allure.story("查询资产:monitorStatus查询")
def test_case_08(self): def test_case_05(self):
name = self.base_name + "08" name = self.base_name + "05"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -163,8 +137,8 @@ class TestDeviceGet(object): ...@@ -163,8 +137,8 @@ class TestDeviceGet(object):
@allure.title("device.get:available查询") @allure.title("device.get:available查询")
@allure.story("查询资产:available查询") @allure.story("查询资产:available查询")
def test_case_09(self): def test_case_06(self):
name = self.base_name + "09" name = self.base_name + "06"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -174,8 +148,8 @@ class TestDeviceGet(object): ...@@ -174,8 +148,8 @@ class TestDeviceGet(object):
@allure.title("device.get:businessIds查询") @allure.title("device.get:businessIds查询")
@allure.story("查询资产:businessIds查询") @allure.story("查询资产:businessIds查询")
def test_case_10(self): def test_case_07(self):
name = self.base_name + "10" name = self.base_name + "7"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -185,8 +159,8 @@ class TestDeviceGet(object): ...@@ -185,8 +159,8 @@ class TestDeviceGet(object):
@allure.title("device.get:memberId查询") @allure.title("device.get:memberId查询")
@allure.story("查询资产:memberId查询") @allure.story("查询资产:memberId查询")
def test_case_11(self): def test_case_08(self):
name = self.base_name + "11" name = self.base_name + "8"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -196,8 +170,8 @@ class TestDeviceGet(object): ...@@ -196,8 +170,8 @@ class TestDeviceGet(object):
@allure.title("device.get:factoryId查询") @allure.title("device.get:factoryId查询")
@allure.story("查询资产:factoryId查询") @allure.story("查询资产:factoryId查询")
def test_case_12(self): def test_case_09(self):
name = self.base_name + "12" name = self.base_name + "09"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -207,8 +181,8 @@ class TestDeviceGet(object): ...@@ -207,8 +181,8 @@ class TestDeviceGet(object):
@allure.title("device.get:manageIp查询") @allure.title("device.get:manageIp查询")
@allure.story("查询资产:manageIp查询") @allure.story("查询资产:manageIp查询")
def test_case_13(self): def test_case_10(self):
name = self.base_name + "13" name = self.base_name + "10"
self.app.case_create_host(name=name, host_type=self.base_type_snmp, self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
...@@ -218,7 +192,7 @@ class TestDeviceGet(object): ...@@ -218,7 +192,7 @@ class TestDeviceGet(object):
@allure.title("device.get:menuId查询") @allure.title("device.get:menuId查询")
@allure.story("查询资产:menuId查询") @allure.story("查询资产:menuId查询")
def test_case_14(self): def test_case_11(self):
response = self.app.device_get(token=self.token, menuId=1) response = self.app.device_get(token=self.token, menuId=1)
self.app.check_code(response=response, code=0) self.app.check_code(response=response, code=0)
......
...@@ -27,13 +27,19 @@ import allure ...@@ -27,13 +27,19 @@ import allure
@allure.feature("测试模块:device.status") @allure.feature("测试模块:device.status")
class TestDeviceStatus(object): class TestDeviceStatus(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
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"]
host_zabbix = env["host_zabbix"]
db_url_zabbix = env["db_url_zabbix"]
db_port_zabbix = env["db_port_zabbix"]
db_user_zabbix = env["db_user_zabbix"]
db_pw_zabbix = env["db_pw_zabbix"]
db_base_zabbix = env["db_base_zabbix"] db_base_zabbix = env["db_base_zabbix"]
login_name = "SS测试用户名" login_name = "SS测试用户名"
...@@ -81,7 +87,8 @@ class TestDeviceStatus(object): ...@@ -81,7 +87,8 @@ class TestDeviceStatus(object):
@allure.step("连接数据库:Zabbix") @allure.step("连接数据库:Zabbix")
def db_session_zabbix(self): 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) session = UtilsDataBase().conn_mysql(db_url=self.db_url_zabbix, db_port=self.db_port_zabbix, db_base=self.db_base_zabbix,
db_user=self.db_user_zabbix, db_pw=self.db_pw_zabbix)
return session return session
@allure.step("查询表:hosts") @allure.step("查询表:hosts")
...@@ -104,37 +111,11 @@ class TestDeviceStatus(object): ...@@ -104,37 +111,11 @@ class TestDeviceStatus(object):
assert x == 0 assert x == 0
assert sql != [] assert sql != []
@allure.title("device.status:token未传")
@allure.story("变更状态:token未传")
@allure.severity("blocker")
def test_case_01(self):
response = self.app.device_status()
self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在")
@allure.title("device.status:token的用户已删除")
@allure.story("变更状态:token的用户已删除")
@allure.severity("blocker")
def test_case_02(self):
self.app.update_members_del_flag(session=self.db_session(), members_id=self.base_id, value=CaseBase().del_flag["ON"])
response = self.app.device_status(token=self.token)
self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在")
@allure.title("device.status:token的用户已禁用")
@allure.story("变更状态:token的用户已禁用")
@allure.severity("blocker")
def test_case_03(self):
self.app.update_members_status(session=self.db_session(), members_id=self.base_id, value=CaseBase().status["OFF"])
response = self.app.device_status(token=self.token)
self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.status:变更一个monitorStatus=0") @allure.title("device.status:变更一个monitorStatus=0")
@allure.story("变更状态:变更一个monitorStatus=0") @allure.story("变更状态:变更一个monitorStatus=0")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
name = self.base_name + "04" name = self.base_name + "01"
host_id = self.app.case_create_host(name=name, host_type=self.base_type_snmp, host_id = self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2], businessIds=[self.base_business_id_1, self.base_business_id_2],
...@@ -146,8 +127,8 @@ class TestDeviceStatus(object): ...@@ -146,8 +127,8 @@ class TestDeviceStatus(object):
@allure.title("device.status:变更一个monitorStatus=1") @allure.title("device.status:变更一个monitorStatus=1")
@allure.story("变更状态:变更一个monitorStatus=1") @allure.story("变更状态:变更一个monitorStatus=1")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_05(self): def test_case_02(self):
name = self.base_name + "05" name = self.base_name + "02"
host_id = self.app.case_create_host(name=name, host_type=self.base_type_snmp, host_id = self.app.case_create_host(name=name, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2], businessIds=[self.base_business_id_1, self.base_business_id_2],
...@@ -163,10 +144,10 @@ class TestDeviceStatus(object): ...@@ -163,10 +144,10 @@ class TestDeviceStatus(object):
@allure.title("device.status:变更多个monitorStatus=0") @allure.title("device.status:变更多个monitorStatus=0")
@allure.story("变更状态:变更多个monitorStatus=0") @allure.story("变更状态:变更多个monitorStatus=0")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_06(self): def test_case_03(self):
name_1 = self.base_name + "061" name_1 = self.base_name + "031"
name_2 = self.base_name + "062" name_2 = self.base_name + "032"
name_3 = self.base_name + "063" name_3 = self.base_name + "033"
host_id_1 = self.app.case_create_host(name=name_1, host_type=self.base_type_snmp, host_id_1 = self.app.case_create_host(name=name_1, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
...@@ -189,10 +170,10 @@ class TestDeviceStatus(object): ...@@ -189,10 +170,10 @@ class TestDeviceStatus(object):
@allure.title("device.status:变更多个monitorStatus=1") @allure.title("device.status:变更多个monitorStatus=1")
@allure.story("变更状态:变更多个monitorStatus=1") @allure.story("变更状态:变更多个monitorStatus=1")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_07(self): def test_case_04(self):
name_1 = self.base_name + "071" name_1 = self.base_name + "041"
name_2 = self.base_name + "072" name_2 = self.base_name + "042"
name_3 = self.base_name + "073" name_3 = self.base_name + "043"
host_id_1 = self.app.case_create_host(name=name_1, host_type=self.base_type_snmp, host_id_1 = self.app.case_create_host(name=name_1, host_type=self.base_type_snmp,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
......
...@@ -28,13 +28,19 @@ from WorkCase.APP import AppBase ...@@ -28,13 +28,19 @@ from WorkCase.APP import AppBase
@allure.feature("测试模块:device.update") @allure.feature("测试模块:device.update")
class TestDeviceUpdate(object): class TestDeviceUpdate(object):
log = UtilsLog() log = UtilsLog()
env = CaseBase().app_environment env = CaseBase().environment_test
host = env["host"] host = env["host"]
db_url = env["db_url"] db_url = env["db_url"]
db_port = env["db_port"] db_port = env["db_port"]
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"]
host_zabbix = env["host_zabbix"]
db_url_zabbix = env["db_url_zabbix"]
db_port_zabbix = env["db_port_zabbix"]
db_user_zabbix = env["db_user_zabbix"]
db_pw_zabbix = env["db_pw_zabbix"]
db_base_zabbix = env["db_base_zabbix"] db_base_zabbix = env["db_base_zabbix"]
login_name = "SS测试用户名" login_name = "SS测试用户名"
...@@ -86,7 +92,8 @@ class TestDeviceUpdate(object): ...@@ -86,7 +92,8 @@ class TestDeviceUpdate(object):
@allure.step("连接数据库:Zabbix") @allure.step("连接数据库:Zabbix")
def db_session_zabbix(self): 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) session = UtilsDataBase().conn_mysql(db_url=self.db_url_zabbix, db_port=self.db_port_zabbix, db_base=self.db_base_zabbix,
db_user=self.db_user_zabbix, db_pw=self.db_pw_zabbix)
return session return session
@allure.step("查询表:hosts") @allure.step("查询表:hosts")
...@@ -159,37 +166,11 @@ class TestDeviceUpdate(object): ...@@ -159,37 +166,11 @@ class TestDeviceUpdate(object):
assert y.ipmi_password == ipmi_password assert y.ipmi_password == ipmi_password
assert x == 0 assert x == 0
@allure.title("device.update:token未传")
@allure.story("更新资产:token未传")
@allure.severity("blocker")
def test_case_01(self):
response = self.app.device_update()
self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在")
@allure.title("device.update:token的用户已删除")
@allure.story("更新资产:token的用户已删除")
@allure.severity("blocker")
def test_case_02(self):
self.app.update_members_del_flag(session=self.db_session(), members_id=self.base_id, value=CaseBase().del_flag["ON"])
response = self.app.device_update(token=self.token)
self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在")
@allure.title("device.update:token的用户已禁用")
@allure.story("更新资产:token的用户已禁用")
@allure.severity("blocker")
def test_case_03(self):
self.app.update_members_status(session=self.db_session(), members_id=self.base_id, value=CaseBase().status["OFF"])
response = self.app.device_update(token=self.token)
self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用")
@allure.title("device.update:更新所有字段") @allure.title("device.update:更新所有字段")
@allure.story("更新资产:更新所有字段") @allure.story("更新资产:更新所有字段")
@allure.severity("blocker") @allure.severity("blocker")
def test_case_04(self): def test_case_01(self):
name = self.base_name + "04" 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_agent,
iplist=self.base_ip, port=self.base_port, iplist=self.base_ip, port=self.base_port,
businessIds=[self.base_business_id_1, self.base_business_id_2]) businessIds=[self.base_business_id_1, self.base_business_id_2])
......
...@@ -13,10 +13,7 @@ from WorkCase.APP import AppBase ...@@ -13,10 +13,7 @@ from WorkCase.APP import AppBase
from WorkUtils.UtilsLog import UtilsLog from WorkUtils.UtilsLog import UtilsLog
from WorkUtils.UtilsResponse import UtilsResponse from WorkUtils.UtilsResponse import UtilsResponse
from WorkUtils.UtilsDataBase import UtilsDataBase from WorkUtils.UtilsDataBase import UtilsDataBase
from WorkApi.APP.Api.api_login import ApiLogin
from WorkApi.APP.Settings.Get.settings_get_member import SettingsGetMember
from WorkData.Argus.members import DataMembers
import allure import allure
...@@ -68,7 +65,7 @@ class TestSettingsGetMember(object): ...@@ -68,7 +65,7 @@ class TestSettingsGetMember(object):
@allure.severity("blocker") @allure.severity("blocker")
def test_case_01(self): def test_case_01(self):
time.sleep(10) time.sleep(10)
response = self.app.settings_get_member(memberId=self.base_id) response = self.app.settings_get_member()
self.app.check_code(response=response, code=2001) self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token不存在") self.app.check_msg(response=response, msg="token不存在")
...@@ -78,7 +75,7 @@ class TestSettingsGetMember(object): ...@@ -78,7 +75,7 @@ class TestSettingsGetMember(object):
def test_case_02(self): def test_case_02(self):
self.app.update_members_del_flag(session=self.db_session(), 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"])
time.sleep(10) time.sleep(10)
response = self.app.settings_get_member(token=self.token, memberId=self.base_id) response = self.app.settings_get_member(token=self.token)
self.app.check_code(response=response, code=2004) self.app.check_code(response=response, code=2004)
self.app.check_msg(response=response, msg="用户不存在") self.app.check_msg(response=response, msg="用户不存在")
...@@ -88,7 +85,7 @@ class TestSettingsGetMember(object): ...@@ -88,7 +85,7 @@ class TestSettingsGetMember(object):
def test_case_03(self): def test_case_03(self):
self.app.update_members_status(session=self.db_session(), 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"])
time.sleep(10) time.sleep(10)
response = self.app.settings_get_member(token=self.token, memberId=self.base_id) response = self.app.settings_get_member(token=self.token)
self.app.check_code(response=response, code=2003) self.app.check_code(response=response, code=2003)
self.app.check_msg(response=response, msg="账户已被禁用") self.app.check_msg(response=response, msg="账户已被禁用")
...@@ -97,7 +94,7 @@ class TestSettingsGetMember(object): ...@@ -97,7 +94,7 @@ class TestSettingsGetMember(object):
def test_case_04(self): def test_case_04(self):
self.app.update_members_status(session=self.db_session(), members_id=self.base_id, value=1) self.app.update_members_status(session=self.db_session(), members_id=self.base_id, value=1)
time.sleep(10) time.sleep(10)
response = self.app.settings_get_member(token="Test", memberId=self.base_id) response = self.app.settings_get_member(token="Test")
self.app.check_code(response=response, code=2001) self.app.check_code(response=response, code=2001)
self.app.check_msg(response=response, msg="token错误,请重新登录") self.app.check_msg(response=response, msg="token错误,请重新登录")
...@@ -106,8 +103,9 @@ class TestSettingsGetMember(object): ...@@ -106,8 +103,9 @@ class TestSettingsGetMember(object):
@allure.severity("blocker") @allure.severity("blocker")
def test_case_05(self): def test_case_05(self):
time.sleep(10) time.sleep(10)
response = self.app.settings_get_member(token=self.token, memberId=self.base_id) response = self.app.settings_get_member(token=self.token)
self.app.check_code(response=response, code=0) self.app.check_code(response=response, code=0)
assert UtilsResponse().get_data(response=response)["name"] == self.login_name
assert UtilsResponse().get_data(response=response)["roleName"] == "管理员角色" assert UtilsResponse().get_data(response=response)["roleName"] == "管理员角色"
......
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