summaryrefslogtreecommitdiff
path: root/cases/object/test_apns.py
blob: 2308dd4e6f0ce540c5bba8adf8f6bc75843df2bb (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# -*- coding: UTF-8 -*-
import configparser
import copy
import os
import time
import pytest
from common.read_data.read_data import ReadData
from common.ui_common.objects.apns import APNs
from cases.conftest import demo_fixture
from common.ui_common.objects.objects_public_operations import download_files
from config.workpath import workdir

data = ReadData()


class TestAPNs:
    @pytest.mark.parametrize("data", [
        {
            "ids": "item_search",
            "CreateModel": "1",
            "CreateType": "APN",
            "Name": "test_vsys_check",
            "SubType": "",
            "Search_type": "Name",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False"
        }
    ])
    def test_sub_objects_drawer_search(self, demo_fixture, data):
        apn = APNs(demo_fixture)
        apn._sub_objects_drawer_search(data)

    @pytest.mark.parametrize("data", [
        {
            "ids": "include添加,exclude打开未添加校验",
            "Name": "test_exclude_not_add",
            "subtype": "0",
        },{
            "ids": "exclude添加,include未添加校验",
            "Name": "test_include_not_add",
            "subtype": "1",
        },{
            "ids": "exclude,include均未添加校验",
            "Name": "test_exclude_include_not_add",
            "subtype": "2",
        },{
            "ids": "exclude,include均添加校验",
            "Name": "test_exclude_include_all_add",
            "subtype": "3",
        }
    ])
    def test_group_include(self,demo_fixture,data):
        apn = APNs(demo_fixture)
        apn.group_object_include(data)

    #24.1.2main pass
    # 对象创建页面搜索框测试08  对象页面item添加狂total数量17
    # 正向name测试
    @pytest.mark.parametrize("data", data.read_data_object("apns.json"), ids=data.generate_id)
    def test_apns(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns.apns_case(data)

    #24.1.2 pass
    # 创建五层嵌套,未全部运行
    @pytest.mark.parametrize("data", [
        {
        "ids": "创建5层嵌套urlgroup008",
        "CreateModel": "0",
        "Search_type": "Name",
        "Name": [
            "4layer_apn_item1",
            "4layer_apn_group2",
            "4layer_apn_group3",
            "4layer_apn_group4",
            "4layer_apn_group5",
        ],
        "importCorrectFile": "False",
        "isCheckName": "False",
        "isCheckObjectFrame":"False",
        "isTestNestGroup":"True"
        }
     ]
    )
    def test_4layer_nesweited_apn_group(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        print(type(data))
        apns.create_4layer_nested_apn_group(data)

    # 24.1.2 pass
    # 输入框测试: 输入框反向测试20 不输入必要数据21;正向测试在apn_case()中实现
    def test_item_input_frame_reverse(self, demo_fixture):
        apns = APNs(demo_fixture)
        apns.item_input_frame_reverse_test()

    #24.1.2pass
    # object引用的相关测试
    @pytest.mark.parametrize("data",
     [
         {
             "ids": "引用验证",
             "Description": "",
             "CreatType": "Tunnel",
             "Name": "quote_test",
             "Search_type": "Name",
             "CreateModel": "0",
             "importCorrectFile": "False",
             "isCheckName": "False",
             "delete_mode":"security"
         }
     ]
     )
    def test_quoted_object_case(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns._quoted_object_case(data)

    # 列设置  pass
    def test_apn_column_settings_case(self, demo_fixture):
        apns = APNs(demo_fixture)
        apns.apn_column_settings_case()

    # page turning pass
    @pytest.mark.parametrize("data", data.read_data_object(r"URLs\\pages_turning.json"), ids=data.generate_id)
    def test_page_turning(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns._goto_subObjectPage()
        apns.objects_po.pages_turning(data)

    # export_one  pass
    @pytest.mark.parametrize("data",
         [
             {
                 "ids": "创建APN并导出验证",
                 "Description": "",
                 "CreatType": "apn",
                 "Search_type": "Name",

                 "importCorrectFile": "",
                 "isCheckName": "",
                 "CreateModel": "0"
             }
         ]
     )
    def test_export_one_apn(self, data):
        driver = download_files()
        apns = APNs(driver)
        apns.export_one_apn(data)
        driver.quit()

    # 测试点:单选数据导出已测试
    # 1.错误情况(单选取消选中目标数据、多选取消选中目标数据)
    # 2.正常情况(单选数据导出,多选导出部分数据,多选导出所有数据)
    # 3.所有数据前都有复选框(全选是否导出所有)

    #search中全局查询存在问题 Search Type为Name  分步测试success
    @pytest.mark.parametrize(
        "data",
        [
            {
                "ids": "01.取消导出:单选、多选选择后取消",
                "Search_type": "Name",
                "Name": "test_cancel_export",
                "SubType": "cancel_export",
                "multi_type": " ",
                "CreateModel": " "
            },
            {
                "ids": "02.多选:全部导出",
                "Search_type": "Name",
                "Name": "multi_export",
                "SubType": "multi_export",
                "multi_type": "all",
                "CreateModel": " "
            },
            {
                "ids": "03.多选:部分导出",
                "Search_type": "Name",
                "Name": "multi_export",
                "SubType": "multi_export",
                "multi_type": "part",
                "CreateModel": " "
            },
            {
                "ids": "04.多选:有group时无法导出",
                "Search_type": "Name",
                "Name": "multi_export",
                "SubType": "multi_export",
                "multi_type": " ",
                "CreateModel": " "
            }
        ]
    )
    def test_export_multi_condition_test(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns.export_multi_condition_test(data)


    # 导入文件  success
    #24.1.2 pass
    #修改
    @pytest.mark.parametrize("data",
         [
             {
                 "ids": "1、导入正确的apn文件",
                 "Description": "",
                 "CreatType": "apn",
                 "Search_type": "Name",
                 "CreateModel": "0",
                 "file_name": "apn.txt",
                 "importCorrectFile": "True",
                 "isCheckName": ""
             },
             {
                 "ids": "2.导入item重复的apn文件",
                 "Description": "",
                 "CreatType": "apn",
                 "Search_type": "Name",
                 "file_type": "duplicate_file",
                 "file_name": "apn_duplicate.txt",
                 "CreateModel": "1",
                 "importCorrectFile": "False",
                 "isCheckName": ""
             },
             {
                 "ids": "3.导入item格式错误的apn文件",
                 "Description": "",
                 "CreatType": "apn",
                 "Search_type": "Name",
                 "file_type": "error_format",
                 "file_name": "apn_error_item.txt",
                 "CreateModel": "1",
                 "importCorrectFile": "True",
                 "isCheckName": ""
            },
             {
                 "ids": "4.导入item长度不符合格式的apn文件",
                 "Description": "",
                 "CreatType": "apn",
                 "Search_type": "Name",
                 "file_type": "error_length",
                 "file_name": "apn_error_length.txt",

                 "CreateModel": "1",
                 "importCorrectFile": "True",
                 "isCheckName": ""
          }
        ]
    )
    def test_apns_import(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns.import_file_test(data)



    #选中All后,除create外其余置灰 ;翻页、创建操作后清除选中状态;列表所有数据前均增加复选框
    #切换页面(翻页、创建、导入等)后清除选中状态
    #上传文件可以下载和删除
    #查看Exclude_Objects开关是否正常
    #不能只选择Exclude Object,否则会出错
    #24.1.2 pass 修改导出按钮位置
    @pytest.mark.parametrize(
        "data",
        [
            {
                "ids": "综合校验",
                "SubType": "ID",
                "Search_type": "Name",
                "Name": "quotedtest"
            }
        ]
    )
    def test_list_check(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns._list_check(data)


    # Auidt Logs
    # 测试点:Audit Logs审计日志
    # 修改名字需要search_type为id
    # 24.1.2 pass  修改侧滑框定位
    # @pytest.mark.parametrize(
    #     "data",
    #     [
    #         {
    #             "ids": "Apn Object Audit Log",
    #             "Search_type": "Name",
    #             "CreateModel":"0",
    #             "importCorrectFile": "False",
    #             "isCheckName": "False",
    #             "isCheckObjectFrame":"False",
    #         },
    #         {
    #             "ids": "Apn Object Group Audit Log",
    #             "Search_type": "Name",
    #             "CreateModel": "1",
    #             "Name":"Audit log",
    #             "importCorrectFile": "False",
    #             "isCheckName": "False",
    #             "isCheckObjectFrame": "False",
    #         }
    #     ]
    # )
    # def test_apns_audit_case(self, demo_fixture, data):
    #     apns = APNs(demo_fixture)
    #     apns._verify_audit_logs(data)


  #Auidt Logs
    # 测试点:Audit Logs审计日志
    # 修改名字需要search_type为id
    # 24.1.2 pass  修改侧滑框定位
    @pytest.mark.parametrize(
        "data",
        [
            {
                "ids": "APN查询case",
                "Search_type": "Name",
                "CreateModel":"0",
                "importCorrectFile": "False",
                "isCheckName": "False",
                "isCheckObjectFrame":"False",
            }
        ]
    )
    def test_apns_query_case(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns.apn_query_case(data)


    def test_item_search_function_in_edit_page(self, demo_fixture):
        apns = APNs(demo_fixture)
        apns.item_search_verify()

    @pytest.mark.parametrize("data", data.read_data_object(r"Ports\\clear_counter.json"), ids=data.generate_id)
    def test_clearCounter(self, demo_fixture, data):
        apns = APNs(demo_fixture)
        apns.test_ClearCounter(data)



    # @pytest.mark.parametrize("data", [
    #     # {
    #     #   "ids": "APN的增删改查",
    #     #   "CreateModel": "0",
    #     #   "CreateType": "APN",
    #     #   "SubType": "",
    #     #   "Search_type": "Name",
    #     #   "importCorrectFile":"False",
    #     #   "isCheckName":"False",
    #     #   "isCheckObjectFrame":"False"
    #     #
    #     # },
    #     {
    #       "ids": "APN Group的增删改查",
    #       "CreateModel": "1",
    #       "CreateType": "APN Group",
    #       "SubType": "",
    #       "Search_type": "Name",
    #       "isCheckObjectFrame":"False",
    #       "Name":"测试APN Group新增的APN"
    #     }
    # ])
    # def test_View_statistics_case(self, demo_fixture, data):
    #     apn = APNs(demo_fixture)
    #     apn._View_statistics_case(data)

    @pytest.mark.parametrize("data", [
        # {
        #     "ids": "用例30-1、多个Object重复item校验",
        #     "Name": "duplicate--2",
        #     "CreateType": "APN",
        #     "repetition_type": "0",
        #     "Search_type": "Name",
        #     "CreateModel": "0",
        #     "importCorrectFile": "False",
        #     "isCheckName": "False",
        #     "isCheckObjectFrame": "False",
        #     "item":"^testaaa.com$"
        # },
        {
            "ids": "用例30-2、多个Object重复item校验",
            "Name": "duplicate--",
            "Createtype": "APN",
            "repetition_type": "1",
            "Search_type": "Name",
            "CreateModel": "0",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "item": "^accc.ggh$"
        }
    ])
    def test_Duplicate_check(self, demo_fixture, data):
        apn = APNs(demo_fixture)
        apn._Repetition_item_case(data)

    @pytest.mark.parametrize("data", [
        {
            "ids": "多个条件组合查询",
            "Name": "duplicate--2",
            "CreateType": "APN",
            "Search_type": "UUID&Name",
            "CreateModel": "0",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "item": "^xiaohongshu.com$"
        },
        {
            "ids": "多个条件组合查询",
            "Name": "duplicate--",
            "Createtype": "APN",
            "Search_type": "Name&Description",
            "CreateModel": "0",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "item": "^xiaohongshu.com$"
        }
    ])
    def test_verify_search(self, demo_fixture, data):
        apn = APNs(demo_fixture)
        apn.verify_search(data)



    # @pytest.mark.parametrize("data", [
    #     {
    #         "ids": "item搜索",
    #         "CreateModel": "0",
    #         "CreateType": "APN",
    #         "SubType": "",
    #         "Search_type": "Name",
    #         "importCorrectFile": "False",
    #         "isCheckName": "False",
    #         "isCheckObjectFrame": "False"
    #     },])
    # def test_item_search(self, demo_fixture, data):
    #     apn = APNs(demo_fixture)
    #     apn.mainPage_item_search(data)


    @pytest.mark.parametrize("data", [{
            "ids": "item搜索",
            "CreateModel": "0",
            "CreateType": "APN",
            "Name":"test_vsys_check",
            "SubType": "",
            "Search_type": "Name",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False"
        }])
    def test_different_vsys_check(self, demo_fixture, data):
        apn = APNs(demo_fixture)
        apn.different_vsys_check(data)



    @pytest.mark.parametrize("data", [
        {
            "ids": "编辑时增量导入",
            "CreateModel": "0",
            "CreateType": "APN",
            "Name": "test_vsys_check",
            "SubType": "",
            "Search_type": "Name",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "file_name": "apn.txt",
        }
    ])
    def test_edit_import_item(self,demo_fixture, data):
        apn = APNs(demo_fixture)
        apn._edit_import_item(data)

    @pytest.mark.parametrize("data", [
        {
            "ids": "导入大量items",
            "CreateModel": "0",
            "CreateType": "APN",
            "Name": "",
            "SubType": "",
            "Search_type": "Name",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "file_name": "apn大量导入10万条数据.txt",
        }
    ])
    def test_import_many_items(self,demo_fixture,data):
        apn = APNs(demo_fixture)
        apn._import_many_items(data)

    @pytest.mark.parametrize("data", [
        {
            "ids": "test_operation_audit_logs",
            "CreateModel": "0",
            "CreateType": "APN",
            "Name": "",
            "SubType": "",
            "Search_type": "Name",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "file_name": "apn.txt",
        }
    ])
    def test_audit_log_all_operation(self, data):
        driver = download_files()
        apns = APNs(driver)
        apns.audit_log_all_operation(data)
        driver.quit()

    @pytest.mark.parametrize("data", [
        {
            "ids": "Name模糊搜索",
            "CreateModel": "0",
            "CreateType": "APN",
            "SubType": "",
            "Search_type": "fuzzy->Name",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "item": ["^asdfs.cn$", "^uiieie.cc$", "^ooewdd.kl$", "^afdsf.eee$"]
        },
        {
            "ids": "Description模糊搜索",
            "CreateModel": "0",
            "CreateType": "APN",
            "SubType": "",
            "Search_type": "fuzzy->Description",
            "importCorrectFile": "False",
            "isCheckName": "False",
            "isCheckObjectFrame": "False",
            "item": ["^asdfs.cn$","^uiieie.cc$","ooewdd.kl$","afdsf.eee$"]
        },
        # {
        #     "ids": "Details模糊搜索",
        #     "CreateModel": "0",
        #     "CreateType": "APN",
        #     "SubType": "",
        #     "Search_type": "fuzzy->Description&Details",
        #     "importCorrectFile": "False",
        #     "isCheckName": "False",
        #     "isCheckObjectFrame": "False",
        #     "item": ["^asdfs.cn$","uiieie.cc$","ooewdd.kl$","afdsf.eee$"]
        # },
    ])
    def test_fuzzy_search(self,demo_fixture,data):
        apn = APNs(demo_fixture)
        apn.fuzzy_search(data)

    @pytest.mark.parametrize("data", [{
        "ids": "策略引用计数跳转验证",
        "CreateModel": "0",
        "CreateType": "APN",
        "Name": "test_policy_quote",
        "SubType": "",
        "Search_type": "Name",
        "importCorrectFile": "False",
        "isCheckName": "False",
        "isCheckObjectFrame": "False"
    }])
    def test_policy_quote_role(self, demo_fixture, data):
        apn = APNs(demo_fixture)
        apn.policy_reference_count_check(data)