diff options
author | reformat <reformat@nobody.nobody> | 2020-04-03 13:05:24 +0200 |
---|---|---|
committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2020-04-03 18:41:28 +0200 |
commit | 787e762445d50ca5b52fafcf8dd6de08ab90916f (patch) | |
tree | afaad3d41a83da180d5fc8bbc7b23d02da7c4dbd /tests/topotests/example-topojson-test | |
parent | Merge pull request #6071 from ton31337/feature/rfc6286 (diff) | |
download | frr-787e762445d50ca5b52fafcf8dd6de08ab90916f.tar.xz frr-787e762445d50ca5b52fafcf8dd6de08ab90916f.zip |
tests: Run python formatter (black) for topotests
Mostly ' => ", whitespace changes.
Using https://github.com/psf/black
Signed-off-by: reformat <reformat@nobody.nobody>
Diffstat (limited to 'tests/topotests/example-topojson-test')
3 files changed, 60 insertions, 57 deletions
diff --git a/tests/topotests/example-topojson-test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py b/tests/topotests/example-topojson-test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py index 8e794b994..f24f463b8 100755 --- a/tests/topotests/example-topojson-test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py +++ b/tests/topotests/example-topojson-test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py @@ -33,8 +33,8 @@ import pytest # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) -sys.path.append(os.path.join(CWD, '../../')) +sys.path.append(os.path.join(CWD, "../")) +sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 from lib.topogen import Topogen, get_topogen @@ -44,19 +44,19 @@ from mininet.topo import Topo # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( - start_topology, write_test_header, - write_test_footer, verify_rib + start_topology, + write_test_header, + write_test_footer, + verify_rib, ) from lib.topolog import logger -from lib.bgp import ( - verify_bgp_convergence -) +from lib.bgp import verify_bgp_convergence from lib.topojson import build_topo_from_json, build_config_from_json # Reading the data from JSON File for topology and configuration creation jsonFile = "{}/example_topojson_multiple_links.json".format(CWD) try: - with open(jsonFile, 'r') as topoJson: + with open(jsonFile, "r") as topoJson: topo = json.load(topoJson) except IOError: assert False, "Could not read file {}".format(jsonFile) @@ -155,8 +155,9 @@ def test_bgp_convergence(request): # Api call verify whether BGP is converged bgp_convergence = verify_bgp_convergence(tgen, topo) - assert bgp_convergence is True, "test_bgp_convergence failed.. \n" \ - " Error: {}".format(bgp_convergence) + assert ( + bgp_convergence is True + ), "test_bgp_convergence failed.. \n" " Error: {}".format(bgp_convergence) logger.info("BGP is converged successfully \n") write_test_footer(tc_name) @@ -167,7 +168,7 @@ def test_static_routes(request): tgen = get_topogen() if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = request.node.name @@ -175,20 +176,19 @@ def test_static_routes(request): # Static routes are created as part of initial configuration, # verifying RIB - dut = 'r3' - protocol = 'bgp' - next_hop = '10.0.0.1' + dut = "r3" + protocol = "bgp" + next_hop = "10.0.0.1" input_dict = {"r1": topo["routers"]["r1"]} # Uncomment below to debug # tgen.mininet_cli() - result = verify_rib(tgen, 'ipv4', dut, input_dict, next_hop=next_hop) - assert result is True, "Testcase {} :Failed \n Error: {}". \ - format(tc_name, result) + result = verify_rib(tgen, "ipv4", dut, input_dict, next_hop=next_hop) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name) -if __name__ == '__main__': +if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/tests/topotests/example-topojson-test/test_topo_json_single_link/test_example_topojson.py b/tests/topotests/example-topojson-test/test_topo_json_single_link/test_example_topojson.py index 315c7b3f2..3ae3c9f4f 100755 --- a/tests/topotests/example-topojson-test/test_topo_json_single_link/test_example_topojson.py +++ b/tests/topotests/example-topojson-test/test_topo_json_single_link/test_example_topojson.py @@ -32,31 +32,31 @@ import pytest # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) -sys.path.append(os.path.join(CWD, '../../')) +sys.path.append(os.path.join(CWD, "../")) +sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 -from lib.topogen import Topogen, get_topogen +from lib.topogen import Topogen, get_topogen # Required to instantiate the topology builder class. from mininet.topo import Topo # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( - start_topology, write_test_header, - write_test_footer, verify_rib + start_topology, + write_test_header, + write_test_footer, + verify_rib, ) from lib.topolog import logger -from lib.bgp import ( - verify_bgp_convergence -) +from lib.bgp import verify_bgp_convergence from lib.topojson import build_topo_from_json, build_config_from_json # Reading the data from JSON File for topology and configuration creation jsonFile = "{}/example_topojson.json".format(CWD) try: - with open(jsonFile, 'r') as topoJson: + with open(jsonFile, "r") as topoJson: topo = json.load(topoJson) except IOError: assert False, "Could not read file {}".format(jsonFile) @@ -65,6 +65,7 @@ except IOError: bgp_convergence = False input_dict = {} + class TemplateTopo(Topo): """ Test topology builder @@ -87,6 +88,7 @@ class TemplateTopo(Topo): # Building topology from json file build_topo_from_json(tgen, topo) + def setup_module(mod): """ Sets up the pytest environment @@ -96,7 +98,7 @@ def setup_module(mod): testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) - logger.info("="*40) + logger.info("=" * 40) logger.info("Running setup_module to create topology") @@ -122,6 +124,7 @@ def setup_module(mod): logger.info("Running setup_module() done") + def teardown_module(mod): """ Teardown the pytest environment @@ -152,8 +155,9 @@ def test_bgp_convergence(request): # Api call verify whether BGP is converged bgp_convergence = verify_bgp_convergence(tgen, topo) - assert bgp_convergence is True, "test_bgp_convergence failed.. \n"\ - " Error: {}".format(bgp_convergence) + assert ( + bgp_convergence is True + ), "test_bgp_convergence failed.. \n" " Error: {}".format(bgp_convergence) logger.info("BGP is converged successfully \n") write_test_footer(tc_name) @@ -164,7 +168,7 @@ def test_static_routes(request): tgen = get_topogen() if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = request.node.name @@ -172,19 +176,18 @@ def test_static_routes(request): # Static routes are created as part of initial configuration, # verifying RIB - dut = 'r3' - next_hop = '10.0.0.1' + dut = "r3" + next_hop = "10.0.0.1" input_dict = {"r1": topo["routers"]["r1"]} # Uncomment below to debug # tgen.mininet_cli() - result = verify_rib(tgen, 'ipv4', dut, input_dict, next_hop=next_hop) - assert result is True, "Testcase {} :Failed \n Error: {}". \ - format(tc_name, result) + result = verify_rib(tgen, "ipv4", dut, input_dict, next_hop=next_hop) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name) -if __name__ == '__main__': +if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/tests/topotests/example-topojson-test/test_topo_json_single_link_loopback/test_example_topojson.py b/tests/topotests/example-topojson-test/test_topo_json_single_link_loopback/test_example_topojson.py index cd069aaec..06fa2f462 100755 --- a/tests/topotests/example-topojson-test/test_topo_json_single_link_loopback/test_example_topojson.py +++ b/tests/topotests/example-topojson-test/test_topo_json_single_link_loopback/test_example_topojson.py @@ -33,32 +33,32 @@ import pytest # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) -sys.path.append(os.path.join(CWD, '../../')) +sys.path.append(os.path.join(CWD, "../")) +sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 # Import topogen and topotest helpers -from lib.topogen import Topogen, get_topogen +from lib.topogen import Topogen, get_topogen # Required to instantiate the topology builder class. from mininet.topo import Topo # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( - start_topology, write_test_header, - write_test_footer, verify_rib + start_topology, + write_test_header, + write_test_footer, + verify_rib, ) from lib.topolog import logger -from lib.bgp import ( - verify_bgp_convergence -) +from lib.bgp import verify_bgp_convergence from lib.topojson import build_topo_from_json, build_config_from_json # Reading the data from JSON File for topology and configuration creation jsonFile = "{}/example_topojson.json".format(CWD) try: - with open(jsonFile, 'r') as topoJson: + with open(jsonFile, "r") as topoJson: topo = json.load(topoJson) except IOError: assert False, "Could not read file {}".format(jsonFile) @@ -100,7 +100,7 @@ def setup_module(mod): testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) - logger.info("="*40) + logger.info("=" * 40) logger.info("Running setup_module to create topology") @@ -157,8 +157,9 @@ def test_bgp_convergence(request): # Api call verify whether BGP is converged bgp_convergence = verify_bgp_convergence(tgen, topo) - assert bgp_convergence is True, "test_bgp_convergence failed.. \n"\ - " Error: {}".format(bgp_convergence) + assert ( + bgp_convergence is True + ), "test_bgp_convergence failed.. \n" " Error: {}".format(bgp_convergence) logger.info("BGP is converged successfully \n") write_test_footer(tc_name) @@ -169,7 +170,7 @@ def test_static_routes(request): tgen = get_topogen() if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = request.node.name @@ -177,8 +178,8 @@ def test_static_routes(request): # Static routes are created as part of initial configuration, # verifying RIB - dut = 'r3' - next_hop = ['10.0.0.1', '10.0.0.5'] + dut = "r3" + next_hop = ["10.0.0.1", "10.0.0.5"] input_dict = { "r1": { "static_routes": [ @@ -186,20 +187,19 @@ def test_static_routes(request): "network": "100.0.20.1/32", "no_of_ip": 9, "admin_distance": 100, - "next_hop": "10.0.0.1" + "next_hop": "10.0.0.1", } ] } } # Uncomment below to debug # tgen.mininet_cli() - result = verify_rib(tgen, 'ipv4', dut, input_dict, next_hop=next_hop) - assert result is True, "Testcase {} :Failed \n Error: {}". \ - format(tc_name, result) + result = verify_rib(tgen, "ipv4", dut, input_dict, next_hop=next_hop) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name) -if __name__ == '__main__': +if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) |