From a15f11a7d273d01572743f918a191b7a6c6c36dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Weing=C3=A4rtner?= Date: Mon, 21 Sep 2020 10:58:40 -0300 Subject: [PATCH] Fix `create_threshold` method when using cost as 0 When using 0 as the cost, the `create_threshold` method throws an exception. That happens because 0 (zero) is evaluated to False. Therefore, we need to change the validation method to check if the values are None. Change-Id: Iedd541c0ad16db0d11d6e6de332eddf880af1698 --- cloudkittyclient/v1/rating/hashmap.py | 2 +- lower-constraints.txt | 20 +++++++++---------- ...ld-method-validation-f193e883e82214c9.yaml | 8 ++++++++ requirements.txt | 18 ++++++++--------- test-requirements.txt | 2 +- 5 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 releasenotes/notes/fix-create_threshold-method-validation-f193e883e82214c9.yaml diff --git a/cloudkittyclient/v1/rating/hashmap.py b/cloudkittyclient/v1/rating/hashmap.py index 142c102..85c02ca 100644 --- a/cloudkittyclient/v1/rating/hashmap.py +++ b/cloudkittyclient/v1/rating/hashmap.py @@ -373,7 +373,7 @@ class HashmapManager(base.BaseManager): :type level: str """ for arg in ['cost', 'level']: - if not kwargs.get(arg): + if kwargs.get(arg) is None: raise exc.ArgumentRequired( "'{}' argument is required".format(arg)) if not kwargs.get('service_id') and not kwargs.get('field_id'): diff --git a/lower-constraints.txt b/lower-constraints.txt index 1939f8f..4721b1f 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -1,18 +1,18 @@ # requirements -pbr==2.0.0 # Apache-2.0 -cliff==2.11.0 # Apache-2.0 -keystoneauth1==3.4.0 # Apache-2.0 -oslo.utils==3.35 # Apache-2.0 -oslo.log==3.36 # Apache-2.0 -PyYAML==3.12 # MIT -jsonpath-rw-ext==1.0 # Apache-2.0 -os-client-config==1.29.0 # Apache-2.0 -osc-lib==1.12.1 # Apache-2.0 +pbr==5.5.1 # Apache-2.0 +cliff==3.5.0 # Apache-2.0 +keystoneauth1==4.3.0 # Apache-2.0 +oslo.utils==4.7.0 # Apache-2.0 +oslo.log==4.4.0 # Apache-2.0 +PyYAML==5.3.1 # MIT +jsonpath-rw-ext==1.2.0 # Apache-2.0 +os-client-config==2.1.0 # Apache-2.0 +osc-lib==2.3.0 # Apache-2.0 # test-requirements.txt pyflakes==2.1.1 coverage==4.0 # Apache-2.0 -python-subunit==0.0.18 # Apache-2.0/BSD +python-subunit==1.4.0 # Apache-2.0/BSD oslotest==1.10.0 # Apache-2.0 stestr==2.0 # Apache-2.0 mock==2.0 # BSD diff --git a/releasenotes/notes/fix-create_threshold-method-validation-f193e883e82214c9.yaml b/releasenotes/notes/fix-create_threshold-method-validation-f193e883e82214c9.yaml new file mode 100644 index 0000000..d183a50 --- /dev/null +++ b/releasenotes/notes/fix-create_threshold-method-validation-f193e883e82214c9.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fix `create_threshold` method when using cost as 0. + When using 0 as the cost, the `create_threshold` method + throws an exception. That happens because 0 (zero) is evaluated + to False. Therefore, we need to change the validation method to + check if the values are None. diff --git a/requirements.txt b/requirements.txt index ee82b98..4ccfab7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,12 +2,12 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr>=2.0.0,!=2.1.0 # Apache-2.0 -cliff>=2.11.0 # Apache-2.0 -keystoneauth1>=3.4.0 # Apache-2.0 -oslo.utils>=3.35 # Apache-2.0 -oslo.log>=3.36 # Apache-2.0 -PyYAML>=3.12 # MIT -jsonpath-rw-ext>=1.0 # Apache-2.0 -os-client-config>=1.29.0 # Apache-2.0 -osc-lib>=1.12.1 # Apache-2.0 +pbr>=5.5.1 # Apache-2.0 +cliff>=3.5.0 # Apache-2.0 +keystoneauth1>=4.3.0 # Apache-2.0 +oslo.utils>=4.7.0 # Apache-2.0 +oslo.log>=4.4.0 # Apache-2.0 +PyYAML>=5.3.1 # MIT +jsonpath-rw-ext>=1.2.0 # Apache-2.0 +os-client-config>=2.1.0 # Apache-2.0 +osc-lib>=2.3.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index e295e84..c24b1e9 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,7 +10,7 @@ hacking>=3.0.1,<3.1.0 # Apache-2.0 pyflakes>=2.1.1 coverage>=4.0,!=4.4 # Apache-2.0 -python-subunit>=0.0.18 # Apache-2.0/BSD +python-subunit>=1.4.0 # Apache-2.0/BSD oslotest>=1.10.0 # Apache-2.0 stestr>=2.0 # Apache-2.0 python-openstackclient>=3.14 # Apache-2.0