# -*- coding: UTF-8 -*- import configparser import copy import os import time import uuid import pytest from selenium import webdriver from common.driver_common.mywebdriver import MyWebDriver from common.read_data.read_data import ReadData from common.ui_common.objects.ip_address import IPAddress 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 Test_ip_address: @pytest.mark.parametrize("data", data.read_data_object("ip_address.json"), ids=data.generate_id) #ip address 增删改查 def test_ip_address(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress.ip_address_case(data) @pytest.mark.parametrize("data",[ { "ids": "用例13、IP的嵌套五层", "Name": "test--1", "Create": { "model": "0", "type": "new_object", "item": [ "1.1.1.1" ] }, "Createtype": "IP", "Subtype": "not_delete", "Search_type": "Name" },{ "ids": "用例13、IP的嵌套五层", "Name": "test--2", "Create": { "model": "1", "type": "quote", "sub_name":"test--1" }, "Createtype": "IP", "Subtype": "not_delete", "Search_type": "Name" },{ "ids": "用例13、IP的嵌套五层", "Name": "test--3", "Create": { "model": "1", "type": "quote", "sub_name":"test--2" }, "Createtype": "IP", "Subtype": "not_delete", "Search_type": "Name" },{ "ids": "用例13、IP的嵌套五层", "Name": "test--", "Create": { "model": "1", "type": "quote", "sub_name":"test--3" }, "Createtype": "IP", "Subtype": "Five_layer", "Search_type": "Name" } ] ) #ip address 增删改查 def test_ip_address_Five_layer_case(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress.ip_address_case(data) def test_Column_settings_case(self,demo_fixture): ipaddress = IPAddress(demo_fixture) ipaddress._Column_settings_case() @pytest.mark.parametrize("data", [ { "ids": "用例6、IP_Group的统计查看", "Name": "test-1", "Create": { "model": "1", "type": "new_object", "item": [ "1.1.1.1", "1.1.1.1-1.1.1.1", "192.168.2.1/24", "1:1:1::1/24", ] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" },{ "ids": "用例1、IP_Object的统计查看", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": [ "1.1.1.1", "1.1.1.1-1.1.1.1", ] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" } ]) def test_View_statistics_case(self,demo_fixture,data): ipaddress = IPAddress(demo_fixture) ipaddress._View_statistics_case(data) @pytest.mark.parametrize("data", [ { "ids": "用例30-1、多个Object重复item校验", "Name": "duplicate--test", "Create": { "model": "0", "type": "new_object", "item": ["192.60.64.28"] }, "Createtype": "IP", "repetition_type": "0", "Subtype": "", "Search_type": "Name" },{ "ids": "用例30-2、Object内重复item校验", "Name": "duplicate--test", "Create": { "model": "0", "type": "new_object", "item": ["random"] }, "Createtype": "IP", "repetition_type": "1", "Subtype": "", "Search_type": "Name" } ]) def test_Duplicate_check(self,demo_fixture,data): ipaddress = IPAddress(demo_fixture) ipaddress.repetition_item_case(data) @pytest.mark.parametrize("data", data.read_data_object(r"Accounts\\clear_counter.json"), ids=data.generate_id) def test_clearCounter(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress._clear_counter(data) @pytest.mark.parametrize("data",[ { "ids": "用例15、对象创建页面的搜索", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": ["1.1.1.1", "192.168.40.40"] }, "Createtype": "IP", "Subtype": "export_files", "Search_type": "IP" } ] ) #ip address 导出文件 def test_ip_address_export_files_case(self, data): driver = download_files() ipaddress = IPAddress(driver) ipaddress.ip_address_case(data) # 用例15、 Watch_button测试 # def test_watch_button_case(self,demo_fixture): # ipaddress = IPAddress(demo_fixture) # ipaddress.watch_button_case() # 用例14、翻页 @pytest.mark.parametrize("data", [ { "turn_mode": 1, "destination_page": "0" }, { "turn_mode": 2, "destination_page": "0" }, { "turn_mode": 3, "destination_page": "0" }, { "turn_mode": 4, "destination_page": "0" } ]) def test_ip_address_page_turn_case(self,demo_fixture,data): ipaddress = IPAddress(demo_fixture) ipaddress._page_turn_case(data) @pytest.mark.parametrize("data",[ { "ids": "用例14、创建Object的审计日志查看", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": ["1.1.1.1", "192.168.40.40"], "item_modify": {"type": "modify", "modify_data": "2.2.2.2"}, }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" },{ "ids": "用例13、IP的嵌套五层", "Name": "test--2->edit-name-test", "Create": { "model": "1", "type": "new_object", "item": [ "1.1.1.1", "192.168.2.1/24", ], }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" } ]) def test_audit_log_case(self,demo_fixture,data): ipaddress = IPAddress(demo_fixture) ipaddress.audit_log_case(data) @pytest.mark.parametrize("data", [ { "ids": "用例31、ID&Name&IP组合查询", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": [ "1.1.1.1", "1.1.1.1-1.1.1.1", "192.168.2.1/24" ] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name&IP" },{ "ids": "用例32、ID&subType&Description组合查询", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": ["$www.baidu.com", "*.example.com"], "Learn From Protocols": ["HTTP", "SSL"], "Aging Times": "10", "Vote Clients Number": "2", "Learned IP Limits": "2" }, "Createtype": "IP_Learning", "Subtype": "", "Search_type": "subType&Description" },{ "ids": "用例33、Name&IP的部分值搜索", "Name": "random", "Create": { "model": "0", "type": "new_object", "item": [ "1.1.1.1", "1.1.1.1-1.1.1.1", "192.168.2.1/24", "1:1:1::1/24", "94E5:E27A::6041" ] }, "Createtype": "IP", "Subtype": "", "Search_type": "fuzzy->Name&IP" },{ "ids": "用例34、Description&Details的部分值查询", "Name": "random", "Create": { "model": "0", "type": "new_object", "item": [ "1.1.1.1", "1.1.1.1-1.1.1.1", "192.168.2.1/24", "1:1:1::1/24", "94E5:E27A::6041" ] }, "Createtype": "IP", "Subtype": "", "Search_type": "fuzzy->Description&Details" } ]) def test_verify_search(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress.verify_search(data) @pytest.mark.parametrize("data", [ { "ids": "用例33、exclude打开未添加校验", "Name": "test-1", "Create": { "model": "1", "type": "new_object", "item": [ "1.1.1.1", ] }, "Createtype": "IP", "Subtype": "0", "Search_type": "subName" },{ "ids": "用例33、exclude添加,include未添加校验", "Name": "test-1", "Subtype": "1", },{ "ids": "用例33、exclude,include均未添加校验", "Name": "test-1", "Subtype": "2", },{ "ids": "用例33、exclude,include均未添加校验", "Name": "test-1", "Create": { "model": "1", "type": "new_object", "item": [ "1.1.1.1", ] }, "Createtype": "IP", "Subtype": "3", "Search_type": "Name" } ]) def test_group_include(self,demo_fixture,data): ipaddress = IPAddress(demo_fixture) ipaddress.group_object_include(data) @pytest.mark.parametrize("data", [ { "ids": "item侧滑框对象item搜索", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": ["192.168.40.40", "1.1.1.1"] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name", "item_search": "IP" }, { "ids": "用例13、IP的嵌套五层", "Name": "test--2", "Create": { "model": "1", "type": "new_object", "item": [ "1.1.1.1", "192.168.2.1/24", ] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" } ]) def test_item_search(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress.mainPage_item_search(data) @pytest.mark.parametrize("data", [{ "ids": "用例14、创建Object的审计日志查看", "Name": "vsys_different-test", "Create": { "model": "0", "type": "new_object", "item": ["1.1.1.1"] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" }]) def test_different_vsys_check(self,demo_fixture,data): ipaddress = IPAddress(demo_fixture) ipaddress.different_vsys_check(data) @pytest.mark.parametrize("data", [ { "ids": "用例13、IP的嵌套五层", "Name": "test--2", "Create": { "model": "1", "type": "new_object", "item": [ "1.1.1.1", "192.168.2.1/24", ] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" } ]) def test_sub_objects_drawer_search(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress._sub_objects_drawer_search(data) @pytest.mark.parametrize("data", [ { "ids": "用例4、IP的修改item", "Name": "test-1", "Create": { "model": "0", "type": "new_object", "item": ["1.1.1.1"], "item_modify": {"type": "modify","modify_data": "2.2.2.2"}, "files_type": "true_files", "files_name": "ip_true_files.txt" }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" } ]) def test_audit_log_all_operation(self,data): driver = download_files() ipaddress = IPAddress(driver) ipaddress.audit_log_all_operation(data) @pytest.mark.parametrize("data", [{ "ids": "用例14、创建Object的审计日志查看", "Name": "test_policy_quote", "Create": { "model": "0", "type": "new_object", "item": ["1.1.1.1"] }, "Createtype": "IP", "Subtype": "", "Search_type": "Name" }]) def test_policy_quote_role(self, demo_fixture, data): ipaddress = IPAddress(demo_fixture) ipaddress.policy_reference_count_check(data) if __name__ == '__main__': # # print(data.read_data_object("moible_identities.json")) # a = time.time() # print(111111111111) pytest.main(['-sv', 'test_ip_address.py', '--check-max-tb=60000']) # # b = time.time() # c = b - aa # print("用时:::", c) # print(3333333333333) """ # 在测试文件的当前路径执行如下命令执行测试用例: pytest –cache-clear -v pytest_json.py --alluredir ./allure # 执行如下命令生成测试报告(自动打开浏览器): allure serve allure """