From e37136d17cf34a4b2c537e5fea98e2188e9127f1 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Tue, 23 Aug 2016 15:19:20 -0700 Subject: [PATCH] Add toggles for modules to symbols file Issues: Fixes #660 Problem: There are cases when you want to run the full test suite, but omit certain checks based on the lack of modules in your bigip install. There is currently no way to ignore these tests without getting creative in your test file location to the py.test command. Analysis: This patch adds the ability to specify modules to turn "on" or "off" in a symbols file when running the funtional tests. Tests: none needed --- symbols.example.yaml | 9 ++++++ test/functional/tm/gtm/test_datacenter.py | 36 ++++++++++++++--------- test/functional/tm/gtm/test_rule.py | 8 +++++ 3 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 symbols.example.yaml diff --git a/symbols.example.yaml b/symbols.example.yaml new file mode 100644 index 000000000..0ad3ce685 --- /dev/null +++ b/symbols.example.yaml @@ -0,0 +1,9 @@ +--- + +bigip_netloc: "localhost" +bigip_port: 10445 +bigip_username: "admin" +bigip_password: "admin" +modules: + gtm: false + ltm: true \ No newline at end of file diff --git a/test/functional/tm/gtm/test_datacenter.py b/test/functional/tm/gtm/test_datacenter.py index 7fd52e546..93a38ebe3 100644 --- a/test/functional/tm/gtm/test_datacenter.py +++ b/test/functional/tm/gtm/test_datacenter.py @@ -17,8 +17,16 @@ from f5.bigip.resource import MissingRequiredCreationParameter from f5.bigip.tm.gtm.datacenter import Datacenter +from pytest import symbols from requests.exceptions import HTTPError +pytestmark = pytest.mark.skipif( + symbols + and hasattr(symbols, 'modules') + and not symbols.modules['gtm'], + reason='The modules symbol for GTM is set to False.' +) + def delete_dc(mgmt_root, name, partition): try: @@ -73,7 +81,7 @@ def test_create_optional_args(self, request, mgmt_root): contact="admin@root.local", description="A datacenter is fine too", location="Between the earth and the moon") - assert False == dc1.enabled + assert dc1.enabled is False assert "admin@root.local" == dc1.contact assert "A datacenter is fine too" == dc1.description assert "Between the earth and the moon" == dc1.location @@ -93,15 +101,15 @@ def test_refresh(self, request, mgmt_root): name='dc1', partition='Common') d2 = mgmt_root.tm.gtm.datacenters.datacenter.load( name='dc1', partition='Common') - assert True == d1.enabled - assert True == d2.enabled + assert d1.enabled is True + assert d2.enabled is True d2.update(enabled=False) - assert False == d2.enabled - assert True == d1.enabled + assert d2.enabled is False + assert d1.enabled is True d1.refresh() - assert False == d1.enabled + assert d1.enabled is False class TestLoad(object): @@ -115,27 +123,27 @@ def test_load(self, request, mgmt_root): setup_basic_test(request, mgmt_root, 'dc1', 'Common') dc1 = mgmt_root.tm.gtm.datacenters.datacenter.load( name='dc1', partition='Common') - assert True == dc1.enabled + assert dc1.enabled is True dc1.update(enabled=False) dc2 = mgmt_root.tm.gtm.datacenters.datacenter.load( name='dc1', partition='Common') - assert False == dc1.enabled - assert False == dc2.enabled + assert dc1.enabled is False + assert dc2.enabled is False class TestUpdate(object): def test_update(self, request, mgmt_root): dc1 = setup_basic_test(request, mgmt_root, 'dc1', 'Common') - assert True == dc1.enabled - assert False == dc1.disabled + assert dc1.enabled is True + assert dc1.disabled is False dc1.update(enabled=False) - assert False == dc1.enabled - assert True == dc1.disabled + assert dc1.enabled is False + assert dc1.disabled is True def test_update_samevalue(self, request, mgmt_root): dc1 = setup_basic_test(request, mgmt_root, 'dc1', 'Common') dc1.update(enabled=True) - assert False != dc1.enabled + assert dc1.enabled is True class TestDelete(object): diff --git a/test/functional/tm/gtm/test_rule.py b/test/functional/tm/gtm/test_rule.py index 98cde95da..9d6de459b 100644 --- a/test/functional/tm/gtm/test_rule.py +++ b/test/functional/tm/gtm/test_rule.py @@ -17,8 +17,16 @@ from f5.bigip.resource import MissingRequiredCreationParameter from f5.bigip.tm.gtm.rule import Rule +from pytest import symbols from requests.exceptions import HTTPError +pytestmark = pytest.mark.skipif( + symbols + and hasattr(symbols, 'modules') + and not symbols.modules['gtm'], + reason='The modules symbol for GTM is set to False.' +) + RULE = '''when LB_SELECTED { set wipHost [LB::server addr]