Skip to content

Commit

Permalink
Raise a TypeError when inputs are not supported types
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-msphere committed Apr 2, 2018
1 parent 7fd97b4 commit b491970
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions dcos_test_utils/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ def add(self, name: str, uri: str, index: int = None) -> dict:
'uri': uri,
'name': name,
}
if index is not None and type(index) == int:

if index is not None:
idx_type = type(index)
if idx_type != int:
raise TypeError('index of type {} is not supported '
'- must be int'.format(idx_type))
params['index'] = index

self._update_headers('repository.add')
Expand Down Expand Up @@ -219,12 +224,18 @@ def install(self, name: str, version: str = None,
}
if version is not None:
params['packageVersion'] = version
if options and type(options) == dict:

if options is not None:
opt_type = type(options)
if opt_type != dict:
raise TypeError('options of type {} is not supported '
'- must be dict'.format(opt_type))
params['options'] = options

if app_id:
params['appId'] = app_id
return self._make_request('install', params,
{'response_version': '2', })
{'response_version': '2'})

def uninstall(self, name: str, app_id: str = None) -> dict:
"""Uninstall a Universe package
Expand Down

0 comments on commit b491970

Please sign in to comment.