Skip to main content

Schul-Cloud Search API

Project description

Build Status Python Package Index Dockerhub Automated Build Status First Timers

These are the tests for the Schul-Cloud search API. You can read motivation blog post about

  • common tests for all search engines

  • testing during live deployment

Installation

You can install the tests by installing Python version 3 and pip. Then, you run the installation from the command line:

pip install --user schul-cloud-search-tests

Installation for Development

If you would like to contribute code to this repository, you can clone it first.

git clone https://github.com/schul-cloud/schul_cloud_search_tests.git
cd schul_cloud_search_tests

Install the required packages for Python:

pip3 install --user -r requirements.txt pip-tools==1.6.5

Note that if you would like to change the requirements, please edit the requirements.in file and run this command to update the dependencies:

pip-compile --output-file requirements.txt requirements.in

Specification

The idea is that these tests run in between your search client and your search engine or search adapter. You use the test interface instead of your search engine interface to run checks on every request the client makes:

  • Is the client request formulated correctly?

  • Is the server response folmulated correctly?

These cases can be defined and are defined:

  • When the client issues a successful request and the server responds correctly, the request is forwarded, optionally including a note that the tests passed.

  • When the client issues a malformed request, HTTP error 400 is returned including the information which tests did not pass. The request is forwarded to the server and the response is expected to be 400, too.

  • When the client issues a correct request, and the server response is malformed, then HTTP error 409 is returned including a list of error descriptions of the mistakes made by the server.

To make the decisions transparent, the client request and the server response are included in the error reponses.

Usage as Proxy

Suppose you have a server running on http://localhost:1234/v1/search/. You can tun the search engine tests as a proxy on port 8080 like this:

python3 -m schul_cloud_search_tests.proxy http://localhost:1234/v1/search 8080 /endpoint/

Now, all your requests to http://localhost:8080/endpoint/ will be forwarded to http://localhost:1234/v1/search.

When you are done, you can visit http://localhost:8080/stop to stop the server or run this command:

python3 -m schul_cloud_search_tests.stop 8080

The return code is zero (success) if all tests of all requests passed. If one test fails, it is a number greater than zero.

Note that the defaults are as follows. The command in each line is the same.

python3 -m schul_cloud_search_tests.proxy http://localhost:8080/v1/search 8081 /v1/search
python3 -m schul_cloud_search_tests.proxy http://localhost:8080/v1/search 8081
python3 -m schul_cloud_search_tests.proxy http://localhost:8080/v1/search
python3 -m schul_cloud_search_tests.proxy

Usage as Tests

In case you have a search engine which should be tested at the URL, you can run tests against it with the following command

python3 -m schul_cloud_search_tests.search http://loalhost:8080/v1/search \
           --query "Q=einstein" --query "Q=test&page[offset]=20"

The tests test the following:

  • There is a search engine running at http://loalhost:8080/v1/search

  • These queries Q=einstein and Q=test&page[offset]=20 are handled correctly.

  • Additional tests are run wich test correct and malformed queries, see Issue 6.

The return status of the tests is zero if all tests passed, otherwise a positive number.

Development Process

The idea is stated in the motivation blog post. We can use the tests to test the search engines. However, the tests can become complex and must be tested themselves. Therefore, the following development process is proposed.

  1. Have a look at the specification:

    The specification is the most important document. It determines what needs to be tested.

  2. Implement tests according to examples of the specification. These tests are located in the schul_cloud_search_tests/tests folder. They test how you would like to have the search proxy respond to the different valid and invalid requests.

  3. Make the tests run.

Further Reading


You can edit this document on Github and check it with this editor.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schul_cloud_search_tests-1.0.68.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

schul_cloud_search_tests-1.0.68-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file schul_cloud_search_tests-1.0.68.tar.gz.

File metadata

File hashes

Hashes for schul_cloud_search_tests-1.0.68.tar.gz
Algorithm Hash digest
SHA256 9be93913f188927ecb1a353accf9a539d727e3005d32ade057f15c9ddfe6b710
MD5 3a808df7a72fdf586399e8a605c422de
BLAKE2b-256 4d563297ea655083ee423711ea2060fedc5ca984492ac8454661485f84a50cb2

See more details on using hashes here.

File details

Details for the file schul_cloud_search_tests-1.0.68-py3-none-any.whl.

File metadata

File hashes

Hashes for schul_cloud_search_tests-1.0.68-py3-none-any.whl
Algorithm Hash digest
SHA256 08e89ca523e805f30cd2f2ad346b7a99d76b38e2c3b11dc5da2e56fdf5577c8e
MD5 c9f0bda9e4d7729d8d2f79807646a22c
BLAKE2b-256 c2699b4ce0eb4744a216973d6d556db33d0fb10db684c84afbf95b00e9640d06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page