Skip to content

Commit

Permalink
Merge pull request #51 from Princeton-CDH/bugfix/update-params
Browse files Browse the repository at this point in the history
fix params bug in index method
  • Loading branch information
kmcelwee committed Oct 14, 2020
2 parents 4e38757 + 439a672 commit 09471d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion parasolr/solr/tests/test_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from unittest.mock import Mock
from unittest.mock import Mock, patch

from parasolr.solr.update import Update

Expand Down Expand Up @@ -54,6 +54,26 @@ def test_index(self, test_client):
resp = test_client.query(q='*:*')
assert resp.numFound == 3

def test_index_override(self, test_client):
with patch.object(test_client.update, 'make_request') as mock_make_request:
# ensure default is properly configured
test_client.update.index([])
args, kwargs = mock_make_request.call_args
assert kwargs['params']['commitWithin'] == test_client.commitWithin

# ensure commitWithin updates with index
test_client.update.index([], commitWithin=1234)
args, kwargs = mock_make_request.call_args
assert kwargs['params']['commitWithin'] == 1234

# ensure a hard commit removes the commitWithin default param and
# configures the new commit param
test_client.update.index([], commit=True)
args, kwargs = mock_make_request.call_args
assert 'commitWithin' not in kwargs['params']
assert kwargs['params']['commit']


def test_delete_by_id(self, test_client):
# add a field and index some documents
test_client.schema.add_field(name='A', type='string')
Expand Down
2 changes: 1 addition & 1 deletion parasolr/solr/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def index(self, docs: list, commit: bool=False,
'post',
url,
data=docs,
params=self.params,
params=params,
headers=self.headers
)

Expand Down

0 comments on commit 09471d9

Please sign in to comment.