Skip to content

Commit 3f98496

Browse files
Alex PecoraroAlex Pecoraro
authored andcommitted
Fixed bug in setter for required params
The model.mustache template defines an if clause for parameters that are required and have validation that looks like this: if not {{param}}: raise ValueError("Invalid value param is 'None'") This part of the template was inherited from the upstream template, the intention of the clause appears to be detect if the parameter is being set to None. However, it causes issues for required parameters that are of type 'integer' or 'float' because a value of 0 or 0.0 will be treated the same as the value of None, which is not correct. This issue was encountered by an SE attempting to utilize the NetworkGroupnetsApi.list_subnets_subnet_pools function, which prior to this fix will throw an exception when the value of the sc_ttl parameter is 0. I added the test script that I used to reproduce the issue and to verify that the change fixes the issue. I also ran all the other test scripts in the tests directory to verify that they all still worked. Also, updated several of the tests to use test_constants.py.
1 parent 6614bd0 commit 3f98496

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

swagger-codegen-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"packageName": "isi_sdk",
3-
"packageVersion": "1.0.1"
3+
"packageVersion": "1.0.2"
44
}

swagger_templates/python/model.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class {{classname}}(object):
9090
{{#hasValidation}}
9191

9292
{{#required}}
93-
if not {{name}}:
93+
if {{name}} is None:
9494
raise ValueError("Invalid value for `{{name}}`, must not be `None`")
9595
{{/required}}
9696
{{#maxLength}}

tests/test_cluster_config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import isi_sdk
22
import urllib3
3+
import test_constants
34

45
urllib3.disable_warnings()
56

67
# configure username and password
7-
isi_sdk.configuration.username = "root"
8-
isi_sdk.configuration.password = "a"
9-
isi_sdk.configuration.verify_ssl = False
8+
isi_sdk.configuration.username = test_constants.USERNAME
9+
isi_sdk.configuration.password = test_constants.PASSWORD
10+
isi_sdk.configuration.verify_ssl = test_constants.VERIFY_SSL
1011

1112
# configure host
12-
host = "https://VNODE2294.west.isilon.com:8080"
13+
host = test_constants.HOST
1314
apiClient = isi_sdk.ApiClient(host)
1415
clusterApi = isi_sdk.ClusterApi(apiClient)
1516

tests/test_event_eventgroup_ocurrences.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import isi_sdk
22
import urllib3
3+
import test_constants
34

45
urllib3.disable_warnings()
56

67
# configure username and password
7-
isi_sdk.configuration.username = "root"
8-
isi_sdk.configuration.password = "a"
9-
isi_sdk.configuration.verify_ssl = False
8+
isi_sdk.configuration.username = test_constants.USERNAME
9+
isi_sdk.configuration.password = test_constants.PASSWORD
10+
isi_sdk.configuration.verify_ssl = test_constants.VERIFY_SSL
1011

1112
# configure host
12-
host = "https://VNODE2294.west.isilon.com:8080"
13+
host = test_constants.HOST
1314
apiClient = isi_sdk.ApiClient(host)
1415
eventApi = isi_sdk.EventApi(apiClient)
1516

tests/test_network_groupnets.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import isi_sdk as isi_sdk
2+
from isi_sdk.rest import ApiException
3+
import urllib3
4+
import test_constants
5+
6+
from pprint import pprint
7+
8+
urllib3.disable_warnings()
9+
10+
# configure username and password
11+
isi_sdk.configuration.username = test_constants.USERNAME
12+
isi_sdk.configuration.password = test_constants.PASSWORD
13+
isi_sdk.configuration.verify_ssl = test_constants.VERIFY_SSL
14+
15+
# configure host
16+
host = test_constants.HOST
17+
api_client = isi_sdk.ApiClient(host)
18+
api_instance = isi_sdk.NetworkGroupnetsApi(api_client)
19+
20+
try:
21+
22+
api_response = \
23+
api_instance.list_subnets_subnet_pools('groupnet0', 'subnet0')
24+
pprint(api_response)
25+
26+
except ApiException as e:
27+
28+
print "Exception when calling list_subnets_subnet_pools: %s\n" % e

tests/test_quotas.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import isi_sdk
22
import urllib3
3+
import test_constants
34

45
urllib3.disable_warnings()
56

67
# configure username and password
7-
isi_sdk.configuration.username = "root"
8-
isi_sdk.configuration.password = "a"
9-
isi_sdk.configuration.verify_ssl = False
8+
isi_sdk.configuration.username = test_constants.USERNAME
9+
isi_sdk.configuration.password = test_constants.PASSWORD
10+
isi_sdk.configuration.verify_ssl = test_constants.VERIFY_SSL
1011

1112
# configure host
12-
host = "https://VNODE2294.west.isilon.com:8080"
13+
host = test_constants.HOST
1314
apiClient = isi_sdk.ApiClient(host)
1415
quotaApi = isi_sdk.QuotaApi(apiClient)
1516

0 commit comments

Comments
 (0)