Skip to main content
https://travis-ci.org/kitconcept/pytest-solr.svg?branch=master Latest Version Egg Status License

Solr process and client fixtures for py.test.

kitconcept

Introduction

pytest-solr is a pytest plugin for the Apache Solr search server. It provides three pytest factories:

solr_process:

For starting and stopping the Solr server. This is session scoped.

solr_core:

For loading and unloading a Solr core configuration. This is module scoped.

solr:

For connecting to a Solr server during a test. This is function scoped.

Solr Process

The solr_process factory starts and stops a the Solr process. An existing Solr executable is required for this.

‘executable’:

path to the Solr executable. Default value is ‘downloads/solr-<SOLR_VERSION>/bin/solr’

‘host’:

hostname where Solr runs. Default value is ‘localhost’.

‘port’:

port Solr uses. Default is value is ‘18983’.

‘core’:

Solr core that is used. Default value is ‘solr’.

‘timeout’:

timeout to wait for Solr to start. Default value is ‘60’ (seconds).

Example:

from pytest_solr.factories import solr_process

solr_process = solr_process(
  executable='solr-6.5.0/bin/solr',
  host='localhost',
  port=8983,
  core='default',
  version='6.5.0',
  timeout=60
)

Solr Core

The solr_core factory adds and removes a Solr core configuration. It expects two parameters, the Solr Process fixture name and the Solr core name.

‘solr_process_fixture_name’:

String with the name of the Solr Process. This is a required parameter.

‘solr_core_name’:

String with the name of the Solr core. Default value is ‘default’.

Example:

from pytest_solr.factories import solr_core

my_solr_core = solr_core('solr_process', 'my_solr_core')

Solr

The Solr factory connects to Solr via pysolr. It expects a single parameter, the Solr core fixture name.

‘solr_core_fixture_name’:

String with the name of the Solr core. This is a required parameter.

Example:

# -*- coding: utf-8 -*-
from pytest_solr.factories import solr_core
from pytest_solr.factories import solr

minimal = solr_core('solr_process', 'minimal')
solr = solr('minimal')

def test_exact_term_match(solr):
    solr.add([{'id': '1', 'title': 'bananas'}])
    assert 1 == solr.search('title:bananas').hits

The solr fixture can then be injected into the test function and used to add documents to solr or search for terms.

See the pysolr documentation. for more details.

Installation

Install pytest-solr with pip:

$ pip install pytest-solr

Usage

Create a solr core with the name ‘minimal’ and inject the use the solr factory into a test function to use it:

# -*- coding: utf-8 -*-
from pytest_solr.factories import solr_core
from pytest_solr.factories import solr

minimal = solr_core('solr_process', 'minimal')
solr = solr('minimal')


def test_exact_term_match(solr):
    solr.add([{'id': '1', 'title': 'bananas'}])
    assert 1 == solr.search('title:bananas').hits

License

Copyright kitconcept GmbH.

Distributed under the terms of the MIT license, pytest-solr is free and Open Source software.

Contribute

Support

If you are having issues, please let us know. If you require professional support feel free to contact us at info@kitconcept.com.

1.0.0 (2020-05-11)

  • Set Solr to always_commit=True. [timo]

  • Black. [timo]

  • Make Solr 7.7.3 the new default. [timo]

1.0a1 (2017-06-22)

  • Initial release. [timo]

Release files for pytest-solr 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-solr 1.0.0
File Size Uploaded
pytest-solr-1.0.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-solr 1.0.0
File Interpreter ABI Platform
pytest_solr-1.0.0-py2-none-any.whl Python 2 none any Details

Total release size: 14.3 kB

Release files / pytest-solr-1.0.0.tar.gz

Download URL pytest-solr-1.0.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b01de963efbd91a049cbc26136c62a28db510d8e7ff3c3ac91d657e9c1416a58
BLAKE2b-256 checksum
How to use checksums
870e8d9208aa71b34abd3c960e91f4e15fe4ea71c696fd62208c75fbd3173ad0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/2.7.17

Release files / pytest_solr-1.0.0-py2-none-any.whl

Download URL pytest_solr-1.0.0-py2-none-any.whl
Size 4.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
650a14700b651722e7da7900d2ed664942659b4e5ad1008e93a6968c2ea68a82
BLAKE2b-256 checksum
How to use checksums
2219f64070275b381dac63a38e3fc8f6782ed6162ff03f70662d719ad29745e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/2.7.17

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page