Пример #1
0
class Test(object):
    def setUp(self):
        self.solr = Solr('http://localhost:8080/solr/collection1')
        self.solr.update( { 'id' : 1 },
                          { 'id' : 2 },
                          { 'id' : 3 },
                          { 'id' : 4 } ).commit()

    def tearDown(self):
        self.solr.delete( ('*', '*') ).commit()

    def test_update(self):
        self.solr.update( { 'id' : 5 } ).commit()
        response = self.solr.select( ('q', '*:*') )
        eq_(len(response.docs), 5)

    def test_commit(self):
        pass

    def test_select(self):
        response = self.solr.select( ('q', 'id:1') )
        eq_(len(response.docs), 1)
        response = self.solr.select( ['q', '*:*'] )
        eq_(len(response.docs), 4)

    def test_get(self):
        response = self.solr.get(1)
        eq_(response.doc['id'], '1')

    def test_delete(self):
        response = self.solr.delete(( 'id', 1 )).commit().select(('q', '*:*'))
        eq_(len(response.docs), 3)

    def test_cores(self):
        response = self.solr.cores()
        ok_('responseHeader' in response and
            'defaultCoreName' in response)

    def test_system(self):
        response = self.solr.system()
        ok_('responseHeader' in response and
            'system' in response)
Пример #2
0
class Test(object):
    def setUp(self):
        self.solr = Solr('http://localhost:8080/solr/collection1')
        self.solr.update({'id': 1}, {'id': 2}, {'id': 3}, {'id': 4}).commit()

    def tearDown(self):
        self.solr.delete(('*', '*')).commit()

    def test_update(self):
        self.solr.update({'id': 5}).commit()
        response = self.solr.select(('q', '*:*'))
        eq_(len(response.docs), 5)

    def test_commit(self):
        pass

    def test_select(self):
        response = self.solr.select(('q', 'id:1'))
        eq_(len(response.docs), 1)
        response = self.solr.select(['q', '*:*'])
        eq_(len(response.docs), 4)

    def test_get(self):
        response = self.solr.get(1)
        eq_(response.doc['id'], '1')

    def test_delete(self):
        response = self.solr.delete(('id', 1)).commit().select(('q', '*:*'))
        eq_(len(response.docs), 3)

    def test_cores(self):
        response = self.solr.cores()
        ok_('responseHeader' in response and 'defaultCoreName' in response)

    def test_system(self):
        response = self.solr.system()
        ok_('responseHeader' in response and 'system' in response)