Avoid quoting `None` as a string in path segments. #90

Closed
wants to merge 2 commits into
from
@@ -162,9 +162,12 @@ def _to_query(cls, obj):
" query string." % obj)
def _join_path(self, path_components):
- """Smush together the (string) path components, ignoring empty ones."""
+ """
+ Smush together the (string) path components.
+ Ignores empty strings and None.
+ """
path = '/'.join(quote_plus(str(p), '') for p in path_components if
- len(str(p)))
+ p is not None and len(str(p)))
if not path.startswith('/'):
path = '/' + path
View
@@ -54,10 +54,16 @@ def test_quoted_chars_in_id(self):
self.assert_result_contains(result, {'_type': 'test-type', '_id': """<>?,./`~!@#$%^&*()_+=[]\{{}|:";'""", 'ok': True, '_index': 'test-index'})
def test_indexing_without_id(self):
- result = self.conn.index('test-index', 'test-type', {'name': 'Joe Tester'})
- self.assert_result_contains(result, {'_type': 'test-type', 'ok': True, '_index': 'test-index'})
+ result = self.conn.index(
+ 'test-index', 'test-type', {'name': 'Joe Tester'})
+ self.assert_result_contains(result,
+ {'_type': 'test-type', 'ok': True, '_index': 'test-index'})
# should have an id of some value assigned.
ok_('_id' in result and result['_id'])
+ # should not generate the same id twice
+ result2 = self.conn.index(
+ 'test-index', 'test-type', {'name': 'Barny Tester'})
+ assert_not_equal(result['_id'], result2['_id'])
def test_explicit_index_create(self):
result = self.conn.create_index('test-index')