Skip to content

Commit dd3316f

Browse files
committed
Fixes the gtm tests and gtm code
Issues: Fixes #519 Problem: When the alias changes were added, GTM datacenter and rule classes were passed over. This patch fixes those classes Analysis: The classes were not using load and create correctly. Tests: Existing tests
1 parent 9f5c086 commit dd3316f

4 files changed

Lines changed: 31 additions & 31 deletions

File tree

f5/bigip/tm/gtm/datacenter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ def create(self, **kwargs):
128128
if 'disabled' in kwargs and kwargs['disabled']:
129129
del kwargs['enabled']
130130

131-
self._create(**kwargs)
132-
self._endis_attrs()
133-
return self
131+
inst = self._create(**kwargs)
132+
inst._endis_attrs()
133+
return inst
134134

135135
def load(self, **kwargs):
136136
kwargs = self._endis_able(kwargs)
137-
self._load(**kwargs)
138-
self._endis_attrs()
139-
return self
137+
inst = self._load(**kwargs)
138+
inst._endis_attrs()
139+
return inst
140140

141141
def refresh(self, **kwargs):
142142
kwargs = self._endis_able(kwargs)

f5/bigip/tm/gtm/rule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
class Rules(Collection):
3535
"""BIG-IP® GTM rule collection"""
36-
def __init__(self, ltm):
37-
super(Rules, self).__init__(ltm)
36+
def __init__(self, gtm):
37+
super(Rules, self).__init__(gtm)
3838
self._meta_data['allowed_lazy_attributes'] = [Rule]
3939
self._meta_data['attribute_registry'] =\
4040
{'tm:gtm:rule:rulestate': Rule}

test/functional/tm/gtm/test_datacenter.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,17 @@
1919
from f5.bigip.tm.gtm.datacenter import Datacenter
2020
from requests.exceptions import HTTPError
2121

22-
pytestmark = pytest.mark.skipif(
23-
True, reason='these tests require the optional gtm module')
24-
2522

2623
def delete_dc(mgmt_root, name, partition):
27-
r = mgmt_root.tm.gtm.datacenters.datacenter
2824
try:
29-
r.load(name=name, partition=partition)
25+
foo = mgmt_root.tm.gtm.datacenters.datacenter.load(
26+
name=name, partition=partition
27+
)
3028
except HTTPError as err:
3129
if err.response.status_code != 404:
3230
raise
3331
return
34-
r.delete()
32+
foo.delete()
3533

3634

3735
def setup_create_test(request, mgmt_root, name, partition):
@@ -81,7 +79,7 @@ def test_create_optional_args(self, request, mgmt_root):
8179
assert "Between the earth and the moon" == dc1.location
8280

8381
def test_create_duplicate(self, request, mgmt_root):
84-
setup_create_test(request, mgmt_root, 'dc1', 'Common')
82+
setup_basic_test(request, mgmt_root, 'dc1', 'Common')
8583
with pytest.raises(HTTPError) as err:
8684
mgmt_root.tm.gtm.datacenters.datacenter.create(
8785
name='dc1', partition='Common')

test/functional/tm/gtm/test_rule.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
from f5.bigip.tm.gtm.rule import Rule
2020
from requests.exceptions import HTTPError
2121

22-
pytestmark = pytest.mark.skipif(
23-
True, reason='these tests require the optional gtm module')
24-
2522

2623
RULE = '''when LB_SELECTED {
2724
set wipHost [LB::server addr]
@@ -30,14 +27,13 @@
3027

3128

3229
def delete_rule(mgmt_root, name, partition):
33-
r = mgmt_root.tm.gtm.rules.rule
3430
try:
35-
r.load(name=name, partition=partition)
31+
foo = mgmt_root.tm.gtm.rules.rule.load(name=name, partition=partition)
3632
except HTTPError as err:
3733
if err.response.status_code != 404:
3834
raise
3935
return
40-
r.delete()
36+
foo.delete()
4137

4238

4339
def setup_create_test(request, mgmt_root, name, partition):
@@ -50,8 +46,9 @@ def setup_basic_test(request, mgmt_root, name, partition):
5046
def teardown():
5147
delete_rule(mgmt_root, name, partition)
5248

53-
rule1 = mgmt_root.tm.gtm.rules.rule
54-
rule1.create(name=name, partition=partition, apiAnonymous=RULE)
49+
rule1 = mgmt_root.tm.gtm.rules.rule.create(
50+
name=name, partition=partition, apiAnonymous=RULE
51+
)
5552
request.addfinalizer(teardown)
5653
return rule1
5754

@@ -69,8 +66,10 @@ def test_create_no_apianonymous(self, mgmt_root):
6966

7067
def test_create(self, request, mgmt_root):
7168
setup_create_test(request, mgmt_root, 'rule1', 'Common')
72-
rule1 = mgmt_root.tm.gtm.rules.rule
73-
rule1.create(name='rule1', partition='Common', apiAnonymous=RULE)
69+
70+
rule1 = mgmt_root.tm.gtm.rules.rule.create(
71+
name='rule1', partition='Common', apiAnonymous=RULE
72+
)
7473
assert rule1.name == 'rule1'
7574
assert rule1.partition == 'Common'
7675
assert rule1.generation and isinstance(rule1.generation, int)
@@ -82,10 +81,11 @@ def test_create(self, request, mgmt_root):
8281

8382
def test_create_optional_args(self, request, mgmt_root):
8483
setup_create_test(request, mgmt_root, 'rule1', 'Common')
85-
rule1 = mgmt_root.tm.gtm.rules.rule
86-
rule1.create(name='rule1', partition='Common',
87-
apiAnonymous=RULE,
88-
check='syntax')
84+
85+
rule1 = mgmt_root.tm.gtm.rules.rule.create(
86+
name='rule1', partition='Common',
87+
apiAnonymous=RULE, check='syntax'
88+
)
8989
assert 'check syntax' in rule1.apiAnonymous
9090

9191
def test_create_duplicate(self, request, mgmt_root):
@@ -164,8 +164,10 @@ def test_delete(self, request, mgmt_root):
164164
class TestRuleCollection(object):
165165
def test_rule_collection(self, request, mgmt_root):
166166
setup_create_test(request, mgmt_root, 'rule1', 'Common')
167-
rule1 = mgmt_root.tm.gtm.rules.rule
168-
rule1.create(name='rule1', partition='Common', apiAnonymous=RULE)
167+
168+
rule1 = mgmt_root.tm.gtm.rules.rule.create(
169+
name='rule1', partition='Common', apiAnonymous=RULE
170+
)
169171
assert rule1.name == 'rule1'
170172
assert rule1.partition == 'Common'
171173
assert rule1.generation and isinstance(rule1.generation, int)

0 commit comments

Comments
 (0)