Exemple #1
0
    def testUpdateDispatch(self):
        url = "http://this.is.a.failure.fail"
        document1 = {"name": "Joe", "surname": "Satriani", "booboo": 12}
        document2 = {
            "name": "Joanna",
            "surname": "S šuuumnikiiiič!",
            "booboo": 12
        }

        solr = Solr({"en": url}, "en")
        solr._send_solr_command = self._command_handler
        solr.add([document1])
        solr.commit()

        self.assertEqual(self.req_urls[0], url)
        self.assertEqual(self.req_urls[1], url)
        self.assertEqual({"add": {
            "doc": document1
        }}, json.loads(self.req_commands[0]))
        self.assertEqual({"commit": {}}, json.loads(self.req_commands[1]))

        self._clear_handler()
        solr.add([document1, document2])
        solr.commit()

        self.assertEqual(self.req_urls[0], url)
        self.assertEqual(self.req_urls[1], url)

        self.assertEqual(
            self.req_commands[0],
            "{\"add\":{\"doc\": %s},\"add\":{\"doc\": %s}}" %
            (json.dumps(document1), json.dumps(document2)))
        self.assertEqual({"commit": {}}, json.loads(self.req_commands[1]))
Exemple #2
0
    def testUpdateDispatch(self):
        url = "http://this.is.a.failure.fail"
        document1 = {u"name": u"Joe", u"surname": u"Satriani", u"booboo": 12}
        document2 = {u"name": u"Joanna", u"surname": u"S šuuumnikiiiič!", u"booboo": 12}

        solr = Solr({"en": url}, "en")
        solr._send_solr_command = self._command_handler
        solr.add([document1])
        solr.commit()

        self.assertEquals(self.req_urls[0], url)
        self.assertEquals(self.req_urls[1], url)
        self.assertEqual({"add": {"doc": document1}}, json.loads(self.req_commands[0]))
        self.assertEqual({"commit": {}}, json.loads(self.req_commands[1]))

        self._clear_handler()
        solr.add([document1, document2])
        solr.commit()

        self.assertEquals(self.req_urls[0], url)
        self.assertEquals(self.req_urls[1], url)

        self.assertEquals(self.req_commands[0], u"{\"add\":{\"doc\": %s},\"add\":{\"doc\": %s}}" % (json.dumps(document1),
                                                                                                    json.dumps(document2)))
        self.assertEqual({"commit": {}}, json.loads(self.req_commands[1]))
Exemple #3
0
    def testUpdateDocBoost(self):
        url = "http://this.is.a.mock.url"
        document1 = {u"name": u"Joe", u"surname": u"Satriani", u"booboo": 12}

        solr = Solr({"en": url}, "en")
        solr._send_solr_command = self._command_handler
        solr.add(document1, boost=10.0)
        solr.commit()
        self.assertEquals(self.req_urls[0], url)
        self.assertEquals(self.req_urls[1], url)
        self.assertEqual({"add": {"doc": document1, "boost": 10.0}}, json.loads(self.req_commands[0]))
        self.assertEqual({"commit": {}}, json.loads(self.req_commands[1]))
Exemple #4
0
    def testUpdateDocBoost(self):
        url = "http://this.is.a.mock.url"
        document1 = {"name": "Joe", "surname": "Satriani", "booboo": 12}

        solr = Solr({"en": url}, "en")
        solr._send_solr_command = self._command_handler
        solr.add(document1, boost=10.0)
        solr.commit()
        self.assertEqual(self.req_urls[0], url)
        self.assertEqual(self.req_urls[1], url)
        self.assertEqual({"add": {
            "doc": document1,
            "boost": 10.0
        }}, json.loads(self.req_commands[0]))
        self.assertEqual({"commit": {}}, json.loads(self.req_commands[1]))
Exemple #5
0
    def testSolrHandlers(self):
        document1 = {"name": "Joe", "surname": "Satriani", "booboo": 12}
        document2 = {"name": "Joanna", "surname": "S šuuumnikiiiič!", "booboo": 12}

        solr = Solr('http://example/solr/core1/')
        solr._send_solr_command = self._command_handler
        solr.add([document1])
        solr.commit()

        solr = Solr('http://example/solr/core2/')
        solr._send_solr_command = self._command_handler
        self.assertEqual(len(solr._add_batch), 0)

        solr.add([document2])
        solr.commit()
Exemple #6
0
    def testSolrHandlers(self):
        document1 = {"name": "Joe", "surname": "Satriani", "booboo": 12}
        document2 = {
            "name": "Joanna",
            "surname": "S šuuumnikiiiič!",
            "booboo": 12
        }

        solr = Solr('http://example/solr/core1/')
        solr._send_solr_command = self._command_handler
        solr.add([document1])
        solr.commit()

        solr = Solr('http://example/solr/core2/')
        solr._send_solr_command = self._command_handler
        self.assertEqual(len(solr._add_batch), 0)

        solr.add([document2])
        solr.commit()