Skip to content

Commit 84a590f

Browse files
authored
Merge pull request #649 from caphrim007/bugfixes.more-coverage-tests-1
Adds coverage tests for test_failover and test_sys_application
2 parents 42b9b81 + 8e4f50f commit 84a590f

3 files changed

Lines changed: 59 additions & 2 deletions

File tree

conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from f5.bigip import BigIP
1717
from f5.bigip import ManagementRoot
18+
from f5.bigip.resource import UnsupportedOperation
1819
from f5.utils.testutils.registrytools import register_device
1920
from icontrol.session import iControlRESTSession
2021
import logging
@@ -217,7 +218,10 @@ def teardown():
217218
after_snapshot = register_device(mgmt_root)
218219
diff = set(after_snapshot) - set(before_snapshot)
219220
for item in diff:
220-
after_snapshot[item].delete()
221+
try:
222+
after_snapshot[item].delete()
223+
except UnsupportedOperation:
224+
pass
221225
request.addfinalizer(teardown)
222226
return before_snapshot
223227

test/functional/tm/sys/test_failover.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ def test_toggle_standby(self, bigip):
7676
pp(f.raw)
7777
assert 'Failover active' in f.apiRawValues['apiAnonymous']
7878

79+
def test_toggle_bad_kwargs_standby(self, mgmt_root):
80+
with pytest.raises(TypeError) as ex:
81+
f = mgmt_root.tm.sys.failover
82+
f.toggle_standby(trafficgroup="traffic-group-1",
83+
state=None, foo="bar")
84+
assert "Unexpected **kwargs" in ex.value.message
85+
7986
def test_attribute_values(self, bigip):
8087
fl = bigip.sys.failover
8188
# Testing both conditions

test/functional/tm/sys/test_sys_application.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def teardown():
9494
return service_s, test_service
9595

9696

97-
def curdle_check(collection, resource, resource_name, **kwargs):
97+
def curdle_check2(collection, resource, resource_name, **kwargs):
9898
name = kwargs['name']
9999
assert resource.name == name
100100
second_resource = getattr(collection, resource_name).load(**kwargs)
@@ -110,6 +110,10 @@ def curdle_check(collection, resource, resource_name, **kwargs):
110110
second_resource.refresh()
111111
assert second_resource.generation == resource.generation
112112

113+
114+
def curdle_check(collection, resource, resource_name, **kwargs):
115+
curdle_check2(collection, resource, resource_name, **kwargs)
116+
113117
assert getattr(collection, resource_name).exists(**kwargs) is True
114118

115119

@@ -119,6 +123,48 @@ def test_get_collection(self, request, bigip):
119123
app_org_full_s = app_org_s.get_collection()
120124
assert len(app_org_full_s) == 4
121125

126+
def test_disallowed_params(self, request, bigip):
127+
"""Tests that a disallowed parameter is removed
128+
129+
This check does not test for failure. Instead, the code in the
130+
associated class will pop the disallowed parameter off of the
131+
kwargs.
132+
133+
Then, the kwargs will be sent through the check_load_parameters,
134+
which checks for "name" and "partition".
135+
136+
Finally, the code will issue a GET request to BIG-IP. If this
137+
method fails, then our disallowed parameter was not removed
138+
properly.
139+
140+
:param mgmt_root:
141+
:return:
142+
"""
143+
serv_s, test_serv = setup_service_test(
144+
request,
145+
bigip,
146+
'test_service2',
147+
'Common',
148+
'test_template2',
149+
'/Common/traffic-group-local-only'
150+
)
151+
# Make sure the uri is what we expect
152+
uri = ''.join([
153+
bigip._meta_data['uri'],
154+
'sys/application/service/~Common',
155+
'~test_service2.app~test_service2'])
156+
assert uri in test_serv._meta_data['uri']
157+
158+
curdle_check2(
159+
serv_s,
160+
test_serv,
161+
'service',
162+
name='test_service2',
163+
partition='Common',
164+
template="bar",
165+
trafficGroup="foo"
166+
)
167+
122168

123169
class TestTemplateCollection(object):
124170
def test_get_collection(self, request, bigip):

0 commit comments

Comments
 (0)