Commit a79008490f88999edc722388b3f700cdd7326ed6
Merge branch 'feature/jipeihong' into 'master'
deleteorg See merge request !5
Showing
6 changed files
with
71 additions
and
36 deletions
tests/Staff-Management/Organization/public_org.py deleted
100644 → 0
tests/Staff-Management/Organization/test_delete_org.py deleted
100644 → 0
1 | -# Author: jipeihong 2017年11月7日14:52:52 | |
2 | - | |
3 | -from atdd.PcPost import PcPost | |
4 | - | |
5 | -class DeleteOrg(PcPost): | |
6 | - | |
7 | - interfaceUrl = "/contact/Apicp/Department/Delete" | |
8 | - | |
9 | - def setUp(self): | |
10 | - self.do_login(self.host, self.mobile, self.psw, self.domain) | |
11 | - | |
12 | - # 查找除了顶级部门之外的所有部门的dpId | |
13 | - def get_all_dpId(self): | |
14 | - url = "/Contact/Apicp/Department/ListChildren" | |
15 | - data = { | |
16 | - "dpParentId": | |
17 | - } | |
18 | - | |
19 | - | |
20 | - def test_delete_org(self): | |
21 | - # data = { | |
22 | - # "department_id": | |
23 | - # } |
tests/Staff_Management/Organization/public_org.py
0 → 100644
1 | + | |
2 | +from atdd.PcPost import PcPost | |
3 | + | |
4 | +class PulbicOrg(PcPost): | |
5 | + | |
6 | + def get_top_org(self): | |
7 | + url = "/Contact/Apicp/Department/List" | |
8 | + data = { | |
9 | + "_identifier": 'contact', | |
10 | + "limit": 99999 | |
11 | + } | |
12 | + result = self.PcPost(url,data) | |
13 | + top_dpId = result['result']['list'][0]['dpId'] | |
14 | + return top_dpId | |
15 | + | |
16 | + # 查找所有部门的dpId,包括顶级部门,以list格式返回 | |
17 | + def get_all_dpId(self): | |
18 | + url = "/Contact/Apicp/Department/ListChildren" | |
19 | + data = { | |
20 | + "dpParentId":self.get_top_org() | |
21 | + } | |
22 | + result = self.PcPost(url,data) | |
23 | + orglist = result['result']['list'] # 组织列表的list信息 | |
24 | + dpIdList = [] | |
25 | + for i in range(len(orglist)): | |
26 | + dpId = orglist[i]['dpId'].split() | |
27 | + # 将dpId加入到dpIdList中 | |
28 | + dpIdList[len(dpIdList):len(dpIdList)] = dpId | |
29 | + return dpIdList | |
30 | + | |
31 | + | |
32 | + | |
33 | + | |
34 | + | ... | ... |
tests/Staff-Management/Organization/test_add_org.py renamed to tests/Staff_Management/Organization/test_add_org.py
1 | 1 | # Author: jipeihong 2017年11月7日14:52:52 |
2 | 2 | |
3 | 3 | from atdd.PcPost import PcPost |
4 | +from tests.Staff_Management.Organization.public_org import PulbicOrg | |
4 | 5 | import random |
5 | 6 | |
6 | 7 | class AddOrg(PcPost): |
7 | 8 | |
8 | - | |
9 | 9 | interfaceUrl = "/contact/Apicp/Department/Save" |
10 | 10 | |
11 | 11 | def setUp(self): |
12 | 12 | self.do_login(self.host, self.mobile, self.psw, self.domain) |
13 | 13 | |
14 | - def get_top_org(self): | |
15 | - url = "/Contact/Apicp/Department/List" | |
16 | - data = { | |
17 | - "_identifier": 'contact', | |
18 | - "limit": 99999 | |
19 | - } | |
20 | - result = self.PcPost(url,data) | |
21 | - top_dpId = result['result']['list'][0]['dpId'] | |
22 | - return top_dpId | |
23 | - | |
24 | - | |
25 | 14 | def test_add_org(self): |
26 | 15 | x = random.randint(0,1000) |
27 | - top_dpId = self.get_top_org() | |
16 | + top_dpId = PulbicOrg().get_top_org() | |
28 | 17 | data = { |
29 | 18 | "department_id": None, |
30 | 19 | "parent_id": top_dpId, # 顶级部门 | ... | ... |
tests/Staff_Management/Organization/test_delete_org.py
0 → 100644
1 | +# Author: jipeihong 2017年11月7日14:52:52 | |
2 | + | |
3 | +from atdd.PcPost import PcPost | |
4 | +from tests.Staff_Management.Organization.public_org import PulbicOrg | |
5 | +import random | |
6 | + | |
7 | +class DeleteOrg(PcPost): | |
8 | + | |
9 | + interfaceUrl = "/contact/Apicp/Department/Delete" | |
10 | + | |
11 | + def setUp(self): | |
12 | + self.do_login(self.host, self.mobile, self.psw, self.domain) | |
13 | + | |
14 | + def test_delete_org(self): | |
15 | + dpIdList = PulbicOrg().get_all_dpId() | |
16 | + if len(dpIdList)>1: | |
17 | + x = random.randint(0,len(dpIdList)-2) #从第一个组织ID到倒数第二个组织ID,去掉顶级部门 | |
18 | + data = { | |
19 | + "department_id": dpIdList[x] | |
20 | + } | |
21 | + result = self.PcPost(self.interfaceUrl,data) | |
22 | + else: # 删除顶级部门 | |
23 | + code = 700 | |
24 | + data = { | |
25 | + "department_id": dpIdList[0] #顶级部门 | |
26 | + } | |
27 | + result = self.PcPostAbnormal(self.interfaceUrl,data,code) | |
28 | + print(result) | |
29 | + return result | |
30 | + | |
31 | + | |
32 | + | |
33 | + | |
34 | + | |
35 | + | ... | ... |
tests/Staff-Management/Organization/test_search_org.py renamed to tests/Staff_Management/Organization/test_search_org.py