diff --git a/.gitignore b/.gitignore index b6b8dd6..df5a05a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ -*.pyc +*.py[co] *.egg-info .tox build/ docs/_build/ dist/ .DS_Store +/bin +/include +/lib +.Python diff --git a/mysolr/mysolr.py b/mysolr/mysolr.py index bfad496..d9b50b2 100644 --- a/mysolr/mysolr.py +++ b/mysolr/mysolr.py @@ -351,7 +351,8 @@ def fetch(self, rows=None): self.query['start'] += self.query['rows'] -def _get_add_xml(array_of_hash, overwrite=True): +def _get_add_xml(array_of_hash, overwrite=True, commit_within=None, + boost_values=None): """ Creates add XML message to send to Solr based on the array of hashes (documents) provided. @@ -359,19 +360,34 @@ def _get_add_xml(array_of_hash, overwrite=True): with the same uniqueKey (default is True) """ - xml = '' % ('true' if overwrite else 'false') + xml = 'bar' + '5')) + + def test_add_xml_nooverwrite(self): + self.assertEqual(mysolr._get_add_xml([{'id': 5, 'foo': 'bar'}], + overwrite=False), + ('bar' + '5')) + + def test_add_xml_commit_within(self): + self.assertEqual(mysolr._get_add_xml([{'id': 5, 'foo': 'bar'}], + commit_within=2.0), + ('' + 'bar5' + '')) + + def test_add_xml_commit_doc_boost(self): + self.assertEqual(mysolr._get_add_xml([{'id': 7, 'foo': 'bar'}], + boost_values={'': 2.3}), + ('' + 'bar7' + '')) + + def test_add_xml_commit_field_boost(self): + self.assertEqual(mysolr._get_add_xml([{'id': 7, 'foo': 'bar'}], + boost_values={'foo': 4.2}), + ('' + 'bar' + '7')) + +if __name__ == '__main__': + unittest.main()