Skip to content

Commit

Permalink
fix duplicating parameters in l7rule update (#226)
Browse files Browse the repository at this point in the history
fix duplicating parameters in l7rule update

_update(self, resource_type, value, base_path=None, **attrs)
Uses value parameter.
And rule has parameter with same name. This cause duplicating exception.
Closes #225

Reviewed-by: Artem Goncharov <[email protected]>
Reviewed-by: Polina Gubina <None>
Reviewed-by: None <None>
  • Loading branch information
anton-sidelnikov authored Sep 9, 2021
1 parent aa9a0c1 commit 7453b8a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions otcextensions/sdk/vlb/v3/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,5 +824,7 @@ def update_l7_rule(self, l7rule, l7_policy, **attrs):
:rtype: :class:`~otcextensions.sdk.vlb.v3.l7_rule.L7Rule`
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
if 'value' in attrs:
attrs['rule_value'] = attrs.pop('value')
return self._update(_l7rule.L7Rule, l7rule,
l7policy_id=l7policyobj.id, **attrs)
4 changes: 2 additions & 2 deletions otcextensions/sdk/vlb/v3/l7_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class L7Rule(resource.Resource):
_query_mapping = resource.QueryParameters(
'admin_state_up', 'compare_type', 'id',
'invert', 'key', 'provisioning_status',
'type', 'value', is_admin_state_up='admin_state_up'
'type', 'rule_value', is_admin_state_up='admin_state_up'
)

# Properties
Expand All @@ -52,4 +52,4 @@ class L7Rule(resource.Resource):
#: Specifies the match content.
type = resource.Body('type')
#: Specifies the value of the match item.
value = resource.Body('value')
rule_value = resource.Body('value')
8 changes: 7 additions & 1 deletion otcextensions/tests/functional/sdk/vlb/v3/test_l7_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ def test_03_find_l7Rule(self):

def test_04_update_l7Rule(self):
compare_type = 'STARTS_WITH'
rule_value = '/testchange.com'
l7p = self.client.update_l7_rule(
TestVlb.l7rule,
TestVlb.l7policy,
compare_type=compare_type,
)
self.assertEqual(l7p['compare_type'], compare_type)

l7p = self.client.update_l7_rule(
TestVlb.l7rule,
TestVlb.l7policy,
value=rule_value,
)
self.assertEqual(l7p['value'], rule_value)
# cleanup
self.client.delete_l7_rule(TestVlb.l7rule, TestVlb.l7policy)
self.client.delete_l7_policy(TestVlb.l7policy)
Expand Down
2 changes: 1 addition & 1 deletion otcextensions/tests/unit/sdk/vlb/v3/test_l7_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ def test_basic(self):
def test_make_it(self):
sot = l7_rule.L7Rule(**EXAMPLE)
self.assertEqual(EXAMPLE['compare_type'], sot.compare_type)
self.assertEqual(EXAMPLE['value'], sot.value)
self.assertEqual(EXAMPLE['value'], sot.rule_value)
self.assertEqual(EXAMPLE['type'], sot.type)

0 comments on commit 7453b8a

Please sign in to comment.