From 84eb4021a903b83eb460d745730b241f59eac8c7 Mon Sep 17 00:00:00 2001 From: David Karchmer Date: Wed, 7 Mar 2018 16:03:16 -0800 Subject: [PATCH] Fix typo in IOTileProjectSlug preventing p--0000-0000 from working (#36) * Fix typo in IOTileProjectSlug preventing p--0000-0000 from working * Allow delete() to take a payload --- CHANGELOG.md | 5 +++++ iotile_cloud/api/connection.py | 9 +++++++-- iotile_cloud/utils/gid.py | 2 +- tests/test_gid.py | 2 ++ version.py | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0ac90..5b81cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/iotile_cloud/api/connection.py b/iotile_cloud/api/connection.py index 3dac093..97ed317 100644 --- a/iotile_cloud/api/connection.py +++ b/iotile_cloud/api/connection.py @@ -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) diff --git a/iotile_cloud/utils/gid.py b/iotile_cloud/utils/gid.py index 9a979a2..adf92c1 100644 --- a/iotile_cloud/utils/gid.py +++ b/iotile_cloud/utils/gid.py @@ -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) diff --git a/tests/test_gid.py b/tests/test_gid.py index 9e88294..a3fce8e 100644 --- a/tests/test_gid.py +++ b/tests/test_gid.py @@ -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') diff --git a/version.py b/version.py index 742dbb9..4f21084 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -version = '0.8.11' +version = '0.8.12'