Skip to content

Commit c877818

Browse files
authored
EMD related bug fixes (#35)
1. IG-15770: "limit" argument for "get_items" accepts only int and not str as documentation mentions 2. IG-15771: "limit" argument for "get_items" returns 1 item when limit=0 3. Removed Pipfile.lock as it differs between py2 and py3
1 parent c6382e9 commit c877818

File tree

5 files changed

+20
-269
lines changed

5 files changed

+20
-269
lines changed

Pipfile.lock

Lines changed: 0 additions & 263 deletions
This file was deleted.

tests/test_client.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class TestEmd(Test):
326326
def setUp(self):
327327
super(TestEmd, self).setUp()
328328

329-
self._path = '/v3io-py-test-emd'
329+
self._path = 'some_dir/v3io-py-test-emd'
330330

331331
def test_emd(self):
332332
items = {
@@ -359,6 +359,20 @@ def test_emd(self):
359359
self.assertEqual('i can smell fear on you', response.output.item['quip'])
360360
self.assertEqual(130, response.output.item['height'])
361361

362+
response = self._client.get_items(container=self._container,
363+
path=self._path,
364+
filter_expression="feature == 'singing'")
365+
self.assertEqual(1, len(response.output.items))
366+
367+
# with limit = 0
368+
received_items = self._client.new_items_cursor(container=self._container,
369+
path=self._path,
370+
attribute_names=['age', 'feature'],
371+
filter_expression='age > 15',
372+
limit=0).all()
373+
374+
self.assertEqual(0, len(received_items))
375+
362376
received_items = self._client.new_items_cursor(container=self._container,
363377
path=self._path,
364378
attribute_names=['age', 'feature'],

v3io/dataplane/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def get_container_contents(self,
126126
True - retrieves only directories (common prefixes)
127127
limit (Optional) : int
128128
Number of objects/directories to receive. default: 1000
129-
marker (Optional) : int
129+
marker (Optional) : str
130130
An opaque identifier that was returned in the NextMarker element of a response to a previous
131131
get_container_contents request that did not return all the requested items. This marker identifies the
132132
location in the path from which to start searching for the remaining requested items.
@@ -496,7 +496,7 @@ def get_items(self,
496496
applicable only together with the ShardingKey request parameter. The scan will return all items with the
497497
specified sharding-key value whose sorting-key values are greater than or equal to (>=) than the value of
498498
the SortKeyRangeStart parameter (if set) and less than (<) the value of the SortKeyRangeEnd parameter.
499-
limit (Optional) : str
499+
limit (Optional) : int
500500
The maximum number of items to return within the response (i.e., the maximum number of elements in the
501501
response object's Items array).
502502
segment (Optional) : str

v3io/dataplane/items_cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def next_item(self):
4545

4646
return self._current_item
4747

48-
if self._current_response and self._current_response.output.last:
48+
if self._current_response and (self._current_response.output.last or len(self._current_items) == 0):
4949
return None
5050

5151
self.marker = self._current_response.output.next_marker if self._current_response else None

v3io/dataplane/request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def encode_get_container_contents(container_name, access_key, kwargs):
6262
if kwargs['directories_only']:
6363
query['prefix-only'] = 1
6464

65-
if kwargs['limit']:
65+
if kwargs['limit'] is not None:
6666
query['max-keys'] = kwargs['limit']
6767

6868
if kwargs['marker']:
@@ -199,7 +199,7 @@ def encode_get_items(container_name, access_key, kwargs):
199199
if kwargs['sharding_key']:
200200
body['ShardingKey'] = kwargs['sharding_key']
201201

202-
if kwargs['limit']:
202+
if kwargs['limit'] is not None:
203203
body['Limit'] = kwargs['limit']
204204

205205
if kwargs['segment']:

0 commit comments

Comments
 (0)