test_delete_org.py
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Author: jipeihong 2017年11月7日14:52:52
from atdd.PcPost import PcPost
from tests.Staff_Management.Organization.public_org import PulbicOrg
import random
class DeleteOrg(PcPost):
interfaceUrl = "/contact/Apicp/Department/Delete"
def setUp(self):
self.do_login(self.host, self.mobile, self.psw, self.domain)
def test_delete_org(self):
top_Id = PulbicOrg().get_top_org()
dpId_all = PulbicOrg().get_all_dpId(top_Id) # 所有部门的dpId
x = random.randint(0, len(dpId_all)-1) # 在所有部门中随机取一个部门
dpIdList = PulbicOrg().get_all_dpId(dpId_all[x]) #获取该部门以及子部门的ID
user_total = PulbicOrg().get_org_user_total(dpId_all[x]) # 获取该该部门的人员总数
if len(dpIdList)>1 or user_total>0 or len(dpId_all)==1 : # 如果存在子部门或人员 或只剩下顶级部门
code = 700
data = {
"department_id": dpIdList[x]
}
result = self.PcPostAbnormal(self.interfaceUrl,data,code)
else: # 删除非顶级部门,且部门下无子部门和人员
data = {
"department_id": dpIdList[0] #顶级部门
}
result = self.PcPost(self.interfaceUrl,data)
print(result)
return result