Skip to content

Commit f1aba4d

Browse files
committed
Add exception check.
1 parent aed56d5 commit f1aba4d

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

f5/bigip/resource.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,4 +1039,15 @@ def load(self, **kwargs):
10391039

10401040

10411041
class Stats(UnnamedResource):
1042+
'''For stats resources.'''
1043+
1044+
def modify(self, **kwargs):
1045+
'''Modify is not supported for unnamed resources
1046+
1047+
:raises: UnsupportedOperation
1048+
'''
1049+
raise UnsupportedMethod(
1050+
"%s does not support the modify method" % self.__class__.__name__
1051+
)
1052+
10421053
pass

test/functional/tm/ltm/test_virtual.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from f5.bigip.resource import MissingRequiredCreationParameter
1919
from f5.bigip.resource import MissingRequiredReadParameter
20+
from f5.sdk_exception import UnsupportedMethod
2021

2122
import copy
2223
from pprint import pprint as pp
@@ -81,7 +82,17 @@ def test_stats(self, request, mgmt_root, setup_device_snapshot):
8182
virtual1, vc1 = setup_virtual_test(
8283
request, mgmt_root, 'Common', 'modtest1'
8384
)
84-
85+
stats = virtual1.stats.load()
86+
assert virtual1.cmpEnabled == u'yes'
87+
assert stats.entries['cmpEnabled']['description'] == u'enabled'
88+
virtual1.modify(cmpEnabled=u'no')
89+
stats.refresh()
90+
assert stats.entries['cmpEnabled']['description'] == u'disabled'
91+
with pytest.raises(UnsupportedMethod) as USMEIO:
92+
stats.modify(description='foo')
93+
assert USMEIO.value.message ==\
94+
"Stats does not support the modify method"
95+
8596

8697
def test_profiles_CE(
8798
mgmt_root, opt_release, setup_device_snapshot

0 commit comments

Comments
 (0)