def test_query(self): dsn = os.environ.get("SOLR_URL", "http://localhost:8983/solr") si = SolrInterface(dsn) si.add(self.docs) si.commit() res = si.query(genre_s="fantasy").execute() self.assertEqual(res.result.numFound, 3) # delete si.delete_by_ids(res.result.docs[0]["id"]) si.commit() res = si.query(genre_s="fantasy").execute() self.assertEqual(res.result.numFound, 2) res = si.query(genre_s="fantasy").execute(constructor=Book) # test constructor self.assertEqual( [x.title for x in res.result.docs], ["The Sea of Monsters", "Sophie's World : The Greek Philosophers"] )
def test_rollback(self): dsn = os.environ.get("SOLR_URL", "http://localhost:8983/solr") si = SolrInterface(dsn) si.delete_all() si.add(self.docs) si.commit() res = si.query(genre_s="fantasy").execute() self.assertEqual(res.result.numFound, 3) # delete res = si.delete_by_ids(res.result.docs[0]['id']) self.assertEqual(res.status, 0) # rollback res = si.rollback() self.assertEqual(res.status, 0) res = si.query(genre_s="fantasy").execute() self.assertEqual(res.result.numFound, 3)
def test_query(self): dsn = os.environ.get("SOLR_URL", "http://localhost:8983/solr") si = SolrInterface(dsn) si.add(self.docs) si.commit() res = si.query(genre_s="fantasy").execute() self.assertEqual(res.result.numFound, 3) # delete res = si.delete_by_ids(res.result.docs[0]['id']) self.assertEqual(res.status, 0) res = si.query(genre_s="fantasy").execute() si.commit() res = si.query(genre_s="fantasy").execute() self.assertEqual(res.result.numFound, 2) res = si.query(genre_s="fantasy").execute(constructor=Book) # test constructor self.assertEqual([x.title for x in res.result.docs], [ u'The Sea of Monsters', u"Sophie's World : The Greek Philosophers" ])