@@ -0,0 +1,2490 @@
+import unittest%0Aimport time%0Afrom solr_doc_manager import SolrDocManager%0Afrom pysolr import Solr%0A%0Aclass SolrDocManagerTester(unittest.TestCase):%0A%0A    def __init__(self):%0A%0A        super(SolrDocManagerTester, self).__init__()%0A        self.solr = Solr(%22http://localhost:8080/solr/%22)%0A%0A    def runTest(self):%0A%0A        #Invalid URL%0A        s = SolrDocManager(%22http://doesntexist.cskjdfhskdjfhdsom%22)%0A        self.assertTrue(s.solr is None)%0A%0A        #valid URL%0A        SolrDoc = SolrDocManager(%22http://localhost:8080/solr/%22)%0A        self.solr.delete(q ='*:*')%0A%0A%0A        #test upsert%0A        docc = %7B'_id': '1', 'name': 'John'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        self.solr.commit()%0A        res = self.solr.search('*:*')%0A        for doc in res:%0A            self.assertTrue(doc%5B'_id'%5D == '1' and doc%5B'name'%5D == 'John')%0A        %0A        docc = %7B'_id': '1', 'name': 'Paul'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        self.solr.commit()%0A        res = self.solr.search('*:*')%0A        for doc in res:%0A            self.assertTrue(doc%5B'_id'%5D == '1' and doc%5B'name'%5D == 'Paul')%0A%0A        #test remove%0A        SolrDoc.remove('1')%0A        self.solr.commit()%0A        res = self.solr.search('*:*')%0A        self.assertTrue(len(res) == 0)%0A%0A        #test search%0A        docc = %7B'_id': '1', 'name': 'John'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        docc = %7B'_id': '2', 'name': 'Paul'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        self.solr.commit()%0A        search = SolrDoc.search('*:*')%0A        search2 = self.solr.search('*:*')%0A        self.assertTrue(len(search) == len(search2))%0A        self.assertTrue(len(search) != 0)%0A        for i in range(0,len(search)):%0A            self.assertTrue(list(search)%5Bi%5D == list(search2)%5Bi%5D)%0A                    %0A        #test solr commit%0A        docc = %7B'_id': '3', 'name': 'Waldo'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        res = SolrDoc.search('Waldo')%0A        assert(len(res) == 0)%0A        time.sleep(1)%0A        res = SolrDoc.search('Waldo')%0A        assert(len(res) != 0)%0A%0A        #test get last doc%0A        docc = %7B'_id': '4', 'name': 'Hare', 'ts': '2'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        docc = %7B'_id': '5', 'name': 'Tortoise', 'ts': '1'%7D%0A        SolrDoc.upsert(%5Bdocc%5D)%0A        self.solr.commit()%0A        doc = SolrDoc.get_last_doc()%0A        self.assertTrue(doc%5B'_id'%5D == '4')%0A%0A        docc = %7B'_id': '6', 'name': 'HareTwin', 'ts':'2'%7D%0A        self.solr.commit()%0A        doc = SolrDoc.get_last_doc()%0A        self.assertTrue(doc%5B'_id'%5D == '4' or doc%5B'_id'%5D == '6');%0A%0A        %0A%0A        %0A

add solr manager test