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
96fc1441
Commit
96fc1441
authored
Dec 23, 2019
by
sanshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整个业务代码重构
parent
bd660c3a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
18 deletions
+32
-18
test_experience_delete.py
WorkCase/APP/Experience/test_experience_delete.py
+3
-3
test_experience_problem_list.py
WorkCase/APP/Experience/test_experience_problem_list.py
+8
-5
test_experience_update.py
WorkCase/APP/Experience/test_experience_update.py
+5
-5
__init__.py
WorkCase/APP/__init__.py
+16
-5
No files found.
WorkCase/APP/Experience/test_experience_delete.py
View file @
96fc1441
...
...
@@ -198,12 +198,12 @@ class TestExperienceDelete(object):
session
=
self
.
db_session
()
self
.
businessid
=
DataBusinesses
()
.
insert_one
(
session
=
session
,
name
=
self
.
name
,
_type
=
1
)
self
.
hostid
=
self
.
app
.
case_create_host
(
self
.
host
_
id
=
self
.
app
.
case_create_host
(
name
=
self
.
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
]
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
hostid
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
host
_
id
)
itemids
=
[]
for
x
,
y
in
enumerate
(
sql
):
itemids
.
append
(
y
.
id
)
...
...
@@ -211,7 +211,7 @@ class TestExperienceDelete(object):
session
=
self
.
db_session
()
DataProblem
()
.
insert_one
(
session
=
session
,
eventid
=
self
.
eventid
,
source
=
0
,
_object
=
0
,
objectid
=
0
,
clock
=
0
,
ns
=
0
,
r_clock
=
0
,
r_ns
=
0
,
acknowledged
=
0
,
acknowledged_time
=
0
,
severity
=
0
,
status
=
0
,
hostid
=
self
.
hostid
,
name
=
self
.
name
)
status
=
0
,
hostid
=
self
.
host
_
id
,
name
=
self
.
name
)
session
=
self
.
db_session
()
DataAlarmRuleTriggers
()
.
insert_one
(
session
=
session
,
hostid
=
self
.
host_id
,
itemid
=
self
.
itemid
,
alarm_ruleid
=
self
.
alarm_ruleid
,
remark
=
"remark"
)
...
...
WorkCase/APP/Experience/test_experience_problem_list.py
View file @
96fc1441
...
...
@@ -12,11 +12,11 @@ import pytest
from
WorkCase.APP
import
AppBase
from
WorkCase.API
import
ApiBase
from
WorkData.Argus.alarm_rule
import
DataAlarmRule
from
WorkData.Argus.alarm_rule_triggers
import
DataAlarmRuleTriggers
from
WorkData.Argus.businesses
import
DataBusinesses
from
WorkData.Argus.experience
import
DataExperience
from
WorkData.Argus.hosts
import
DataHosts
from
WorkData.Argus.hosts_items
import
DataHostsItems
from
WorkData.Argus.members
import
DataMembers
from
WorkData.Argus.problem
import
DataProblem
from
WorkData.Argus.tag
import
DataTag
from
WorkData.Zabbix.problem
import
DataProblem
as
ZabbixDataProblem
...
...
@@ -24,7 +24,6 @@ from WorkData.Zabbix.events import DataEvents
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
from
WorkUtils.UtilsResponse
import
UtilsResponse
from
WorkApi.APP.Experience.Problem.experience_problem_list
import
ExperienceProblemList
from
WorkCase
import
CaseBase
...
...
@@ -125,12 +124,12 @@ class TestExperienceProblemList(object):
session
=
self
.
db_session
()
self
.
businessid
=
DataBusinesses
()
.
insert_one
(
session
=
session
,
name
=
self
.
name
,
_type
=
1
)
self
.
hostid
=
self
.
app
.
case_create_host
(
self
.
host
_
id
=
self
.
app
.
case_create_host
(
name
=
self
.
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
]
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
hostid
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
host
_
id
)
itemids
=
[]
for
x
,
y
in
enumerate
(
sql
):
itemids
.
append
(
y
.
id
)
...
...
@@ -138,7 +137,11 @@ class TestExperienceProblemList(object):
session
=
self
.
db_session
()
DataProblem
()
.
insert_one
(
session
=
session
,
eventid
=
self
.
eventid
,
source
=
0
,
_object
=
0
,
objectid
=
0
,
clock
=
0
,
ns
=
0
,
r_clock
=
0
,
r_ns
=
0
,
acknowledged
=
0
,
acknowledged_time
=
0
,
severity
=
0
,
status
=
0
,
hostid
=
self
.
hostid
,
name
=
self
.
name
)
status
=
0
,
hostid
=
self
.
host_id
,
name
=
self
.
name
)
session
=
self
.
db_session
()
DataAlarmRuleTriggers
()
.
insert_one
(
session
=
session
,
hostid
=
self
.
host_id
,
itemid
=
self
.
itemid
,
alarm_ruleid
=
self
.
alarm_ruleid
,
remark
=
"remark"
)
@allure.step
(
"连接数据库:Argus"
)
def
db_session
(
self
):
...
...
WorkCase/APP/Experience/test_experience_update.py
View file @
96fc1441
...
...
@@ -195,12 +195,12 @@ class TestExperienceUpdate(object):
session
=
self
.
db_session
()
self
.
businessid
=
DataBusinesses
()
.
insert_one
(
session
=
session
,
name
=
self
.
name
,
_type
=
1
)
self
.
hostid
=
self
.
app
.
case_create_host
(
self
.
host
_
id
=
self
.
app
.
case_create_host
(
name
=
self
.
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
]
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
hostid
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
host
_
id
)
itemids
=
[]
for
x
,
y
in
enumerate
(
sql
):
itemids
.
append
(
y
.
id
)
...
...
@@ -208,7 +208,7 @@ class TestExperienceUpdate(object):
session
=
self
.
db_session
()
DataProblem
()
.
insert_one
(
session
=
session
,
eventid
=
self
.
eventid
,
source
=
0
,
_object
=
0
,
objectid
=
0
,
clock
=
0
,
ns
=
0
,
r_clock
=
0
,
r_ns
=
0
,
acknowledged
=
0
,
acknowledged_time
=
0
,
severity
=
0
,
status
=
0
,
hostid
=
self
.
hostid
,
name
=
self
.
name
)
status
=
0
,
hostid
=
self
.
host
_
id
,
name
=
self
.
name
)
session
=
self
.
db_session
()
DataAlarmRuleTriggers
()
.
insert_one
(
session
=
session
,
hostid
=
self
.
host_id
,
itemid
=
self
.
itemid
,
alarm_ruleid
=
self
.
alarm_ruleid
,
remark
=
"remark"
)
...
...
@@ -230,7 +230,7 @@ class TestExperienceUpdate(object):
businessIds
=
[
self
.
base_business_id_1
,
self
.
base_business_id_2
]
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
hostid
)
sql
=
self
.
select_hosts_items
(
host_id
=
self
.
host
_
id
)
itemids
=
[]
for
x
,
y
in
enumerate
(
sql
):
itemids
.
append
(
y
.
id
)
...
...
@@ -238,7 +238,7 @@ class TestExperienceUpdate(object):
session
=
self
.
db_session
()
DataProblem
()
.
insert_one
(
session
=
session
,
eventid
=
self
.
update_eventid
,
source
=
0
,
_object
=
0
,
objectid
=
0
,
clock
=
0
,
ns
=
0
,
r_clock
=
0
,
r_ns
=
0
,
acknowledged
=
0
,
acknowledged_time
=
0
,
severity
=
0
,
status
=
0
,
hostid
=
self
.
hostid
,
name
=
self
.
update_name
)
status
=
0
,
hostid
=
self
.
host
_
id
,
name
=
self
.
update_name
)
@allure.step
(
"查询表:hosts_items"
)
def
select_hosts_items
(
self
,
host_id
=
None
):
...
...
WorkCase/APP/__init__.py
View file @
96fc1441
...
...
@@ -2,7 +2,6 @@
# Argus模块公共封装类
# 作者: 陈磊
# 时间: 2019-12-17
import
time
from
WorkApi.APP.AddressBook.Iplist.addressbook_iplist_get
import
AddressBookIplistGet
from
WorkApi.APP.AddressBook.addressbook_create
import
AddressBookCreate
...
...
@@ -71,6 +70,10 @@ from WorkApi.APP.Inspection.Rule.inspection_rule_delete import InspectionRuleDel
from
WorkApi.APP.Inspection.Rule.inspection_rule_get
import
InspectionRuleGet
from
WorkApi.APP.Inspection.Rule.inspection_rule_update
import
InspectionRuleUpdate
from
WorkApi.APP.Inspection.Rule.inspection_rule_status
import
InspectionRuleStatus
from
WorkApi.APP.Inspection.inspection_doInspection
import
InspectionDoInspection
from
WorkApi.APP.Inspection.inspection_result
import
InspectionResult
from
WorkApi.APP.Inspection.History.inspection_history_get
import
InspectionHistoryGet
from
WorkApi.APP.Inspection.History.inspection_history_result
import
InspectionHistoryResult
class
AppBase
(
object
):
...
...
@@ -522,10 +525,9 @@ class AppBase(object):
return
api
.
response
@allure.step
(
"调用接口:settings.get.member"
)
def
settings_get_member
(
self
,
token
=
None
,
memberId
=
None
):
def
settings_get_member
(
self
,
token
=
None
):
api
=
SettingsGetMember
(
_host
=
self
.
host
)
api
.
token
=
token
api
.
memberId
=
memberId
api
.
get_response
()
return
api
.
response
...
...
@@ -1016,9 +1018,18 @@ class AppBase(object):
return
api
.
response
@allure.step
(
"创建测试数据-巡检任务"
)
def
case_create_inspection_rule
(
self
,
name
=
None
,
time
=
None
,
period
=
None
,
_type
=
None
,
hosts
=
None
,
status
=
None
):
response
=
self
.
inspection_rule_create
(
token
=
self
.
token
,
name
=
name
,
time
=
time
,
period
=
period
,
_type
=
_type
,
hosts
=
hosts
,
status
=
status
)
def
case_create_inspection_rule
(
self
,
name
=
None
,
_
time
=
None
,
period
=
None
,
_type
=
None
,
hosts
=
None
,
status
=
None
):
response
=
self
.
inspection_rule_create
(
token
=
self
.
token
,
name
=
name
,
time
=
_
time
,
period
=
period
,
_type
=
_type
,
hosts
=
hosts
,
status
=
status
)
self
.
check_code
(
response
=
response
,
code
=
0
)
data
=
UtilsResponse
()
.
get_data
(
response
=
response
)
rule_id
=
data
[
0
]
return
rule_id
@allure.step
(
"调用接口:inspection.doinspections"
)
def
inspection_doInspections
(
self
,
token
=
None
,
_id
=
None
,
status
=
None
):
api
=
InspectionDoInspection
(
_host
=
self
.
host
)
api
.
token
=
token
api
.
id
=
_id
api
.
status
=
status
api
.
get_response
()
return
api
.
response
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