Skip to content

Commit

Permalink
Fix typo in IOTileProjectSlug preventing p--0000-0000 from working (#36)
Browse files Browse the repository at this point in the history
* Fix typo in IOTileProjectSlug preventing p--0000-0000 from working

* Allow delete() to take a payload
  • Loading branch information
dkarchmer authored Mar 8, 2018
1 parent b9eca57 commit 84eb402
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v0.8.12 (2018-03-07)

* Fix typo in IOTileProjectSlug preventing `p--0000-0000` from been accepted as valid.
* Allow delete() to accept data

### v0.8.11 (2018-03-04)

* Change IOTileDeviceSlug back to accepting 64bits by default, but add a new allow_64bits option to be turned off
Expand Down
9 changes: 7 additions & 2 deletions iotile_cloud/api/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,15 @@ def put(self, data=None, **kwargs):

return self._process_response(resp)

def delete(self, **kwargs):
def delete(self, data=None, **kwargs):
if data:
payload = json.dumps(data)
else:
payload = None

try:
resp = requests.delete(
self.url(), headers=self._get_header(), params=kwargs, verify=self._store['verify']
self.url(), headers=self._get_header(), data=payload, params=kwargs, verify=self._store['verify']
)
except requests.exceptions.SSLError as err:
raise HttpCouldNotVerifyServerError("Could not verify the server's SSL certificate", err)
Expand Down
2 changes: 1 addition & 1 deletion iotile_cloud/utils/gid.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, id):

# Convert to int and back to get rid of anything above 48 bits
id = gid2int(pid)
if id <= 0 or id >= pow(16, 8):
if id < 0 or id >= pow(16, 8):
raise ValueError('IOTileProjectSlug: UUID should be greater than zero and less than 16^8')
pid = int2pid(id)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_gid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def test_project_slug(self):
# We allow projects to be zero as we use that to represent no project
id = IOTileProjectSlug(0)
self.assertEqual(str(id), 'p--0000-0000')
id = IOTileProjectSlug('p--0000-0000')
self.assertEqual(str(id), 'p--0000-0000')

id = IOTileProjectSlug('p--0000-1234')
self.assertEqual(str(id), 'p--0000-1234')
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.8.11'
version = '0.8.12'

0 comments on commit 84eb402

Please sign in to comment.