Ejemplo n.º 1
0
    def test_solr_offline(self, monkeypatch, monkeytime):
        mock_post = MagicMock(side_effect=ConnectError('', request=None))
        monkeypatch.setattr(httpx, "post", mock_post)

        solr_update(
            [CommitRequest()],
            solr_base_url="http://localhost:8983/solr/foobar",
        )

        assert mock_post.call_count > 1
Ejemplo n.º 2
0
    def test_bad_apple_in_solr_request(self, monkeypatch, monkeytime):
        mock_post = MagicMock(return_value=self.sample_individual_error())
        monkeypatch.setattr(httpx, "post", mock_post)

        solr_update(
            [CommitRequest()],
            solr_base_url="http://localhost:8983/solr/foobar",
        )

        assert mock_post.call_count == 1
Ejemplo n.º 3
0
    def test_non_json_solr_503(self, monkeypatch, monkeytime):
        mock_post = MagicMock(return_value=self.sample_response_503())
        monkeypatch.setattr(httpx, "post", mock_post)

        solr_update(
            [CommitRequest()],
            solr_base_url="http://localhost:8983/solr/foobar",
        )

        assert mock_post.call_count > 1
Ejemplo n.º 4
0
    def test_other_non_ok_status(self, monkeypatch, monkeytime):
        mock_post = MagicMock(
            return_value=Response(500, request=MagicMock(), content="{}"))
        monkeypatch.setattr(httpx, "post", mock_post)

        solr_update(
            [CommitRequest()],
            solr_base_url="http://localhost:8983/solr/foobar",
        )

        assert mock_post.call_count > 1
Ejemplo n.º 5
0
 def _solr_commit(self):
     logger.info("BEGIN commit")
     update_work.solr_update([CommitRequest()])
     logger.info("END commit")