Child: [ddf08c] (diff)

Download this file

test_solr.py    31 lines (26 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest
import mock
from allura.lib.solr import Solr
class TestSolr(unittest.TestCase):
@mock.patch('allura.lib.solr.pysolr')
def setUp(self, pysolr):
self.solr = Solr('server', commit=False, commitWithin='10000')
@mock.patch('allura.lib.solr.pysolr')
def test_add(self, pysolr):
s = self.solr
s.add('foo', commit=True, commitWithin=None)
pysolr.Solr.add.assert_called_once_with(s, 'foo', commit=True,
commitWithin=None)
pysolr.reset_mock()
s.add('bar', somekw='value')
pysolr.Solr.add.assert_called_once_with(s, 'bar', commit=False,
commitWithin='10000', somekw='value')
@mock.patch('allura.lib.solr.pysolr')
def test_delete(self, pysolr):
s = self.solr
s.delete('foo', commit=True)
pysolr.Solr.delete.assert_called_once_with(s, 'foo', commit=True)
pysolr.reset_mock()
s.delete('bar', somekw='value')
pysolr.Solr.delete.assert_called_once_with(s, 'bar', commit=False,
somekw='value')