def test__get(self): resp_body = self.solr._get({'id': 'doc_1'}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['doc']['id'], 'doc_1') resp_body = self.solr._get({'ids': 'doc_1,doc_2'}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 2)
def test__select(self): # Short params. resp_body = self.solr._select({'q': 'doc'}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 3) # Long params. resp_body = self.solr._select({'q': 'doc' * 1024}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 0) self.assertEqual(len(resp_data['responseHeader']['params']['q']), 3 * 1024)
def test__select(self): # Short params. resp_body = self.solr._select({'q': 'doc'}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 3) # Long params. resp_body = self.solr._select({'q': 'doc' * 1024}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 0) self.assertEqual(len(resp_data['responseHeader']['params']['q']), 3 * 1024) # Test Deep Pagination CursorMark resp_body = self.solr._select({'q': '*', 'cursorMark': '*', 'sort': 'id desc', 'start': 0, 'rows': 2}) resp_data = json.loads(resp_body) self.assertEqual(len(resp_data['response']['docs']), 2) self.assertIn('nextCursorMark', resp_data)
def test__select(self): # Short params. resp_body = self.solr._select({"q": "doc"}) resp_data = json.loads(resp_body) self.assertEqual(resp_data["response"]["numFound"], 3) # Long params. resp_body = self.solr._select({"q": "doc" * 1024}) resp_data = json.loads(resp_body) self.assertEqual(resp_data["response"]["numFound"], 0) self.assertEqual(len(resp_data["responseHeader"]["params"]["q"]), 3 * 1024) # Test Deep Pagination CursorMark resp_body = self.solr._select({"q": "*", "cursorMark": "*", "sort": "id desc", "start": 0, "rows": 2}) resp_data = json.loads(resp_body) self.assertEqual(len(resp_data["response"]["docs"]), 2) self.assertIn("nextCursorMark", resp_data)
def test__select(self): # Short params. resp_body = self.solr._select({"q": "doc"}) resp_data = json.loads(resp_body) self.assertEqual(resp_data["response"]["numFound"], 3) # Long params. resp_body = self.solr._select({"q": "doc" * 1024}) resp_data = json.loads(resp_body) self.assertEqual(resp_data["response"]["numFound"], 0) self.assertEqual(len(resp_data["responseHeader"]["params"]["q"]), 3 * 1024) # Test Deep Pagination CursorMark resp_body = self.solr._select( {"q": "*", "cursorMark": "*", "sort": "id desc", "start": 0, "rows": 2} ) resp_data = json.loads(resp_body) self.assertEqual(len(resp_data["response"]["docs"]), 2) self.assertIn("nextCursorMark", resp_data)
def test__mlt(self): resp_body = self.solr._mlt({'q': 'id:doc_1', 'mlt.fl': 'title'}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 0)
def test__suggest_terms(self): resp_body = self.solr._select({"terms.fl": "title"}) resp_data = json.loads(resp_body) self.assertEqual(resp_data["response"]["numFound"], 0)
def test__mlt(self): resp_body = self.solr._mlt({"q": "id:doc_1", "mlt.fl": "title"}) resp_data = json.loads(resp_body) self.assertEqual(resp_data["response"]["numFound"], 0)
def json(self): return json.loads(self.content)
def test__suggest_terms(self): resp_body = self.solr._select({'terms.fl': 'title'}) resp_data = json.loads(resp_body) self.assertEqual(resp_data['response']['numFound'], 0)