Package: schul-cloud-search-tests
These are the tests for theSchul-Cloud search API.
You can readmotivation blog postaboutcommon tests for all search enginestesting during live deploymentInstallationYou can install the tests by installingPythonversion 3 andpip.
Then, you run the installation from the command line:pipinstall--userschul-cloud-search-testsInstallation for DevelopmentIf you would like to contribute code to this repository, you can clone it first.gitclonehttps://github.com/schul-cloud/schul_cloud_search_tests.gitcdschul_cloud_search_testsInstall the required packages forPython:pip3install--user-rrequirements.txtpip-tools==1.6.5Note that if you would like to change the requirements, please edit therequirements.infile and run this command to update the dependencies:pip-compile--output-filerequirements.txtrequirements.inSpecificationThe 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 error400is returned
including the information which tests did not pass.
The request is forwarded to the server and the response is expected to be400, too.When the client issues a correct request, and the server response is malformed,
then HTTP error409is 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 ProxySuppose you have a server running onhttp://localhost:1234/v1/search/.
You can tun the search engine tests as a proxy on port 8080 like this:python3-mschul_cloud_search_tests.proxyhttp://localhost:1234/v1/search8080/endpoint/Now, all your requests tohttp://localhost:8080/endpoint/will be forwarded tohttp://localhost:1234/v1/search.When you are done, you can visithttp://localhost:8080/stopto stop the server
or run this command:python3-mschul_cloud_search_tests.stop8080The 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-mschul_cloud_search_tests.proxyhttp://localhost:8080/v1/search8081/v1/searchpython3-mschul_cloud_search_tests.proxyhttp://localhost:8080/v1/search8081python3-mschul_cloud_search_tests.proxyhttp://localhost:8080/v1/searchpython3-mschul_cloud_search_tests.proxyUsage as TestsIn case you have a search engine which should be tested at the URL, you can run tests against it with the following commandpython3-mschul_cloud_search_tests.searchhttp://localhost:8080/v1/search\--query"Q=einstein"--query"Q=test&page[offset]=20"The tests test the following:There is a search engine running athttp://localhost:8080/v1/searchThese queriesQ=einsteinandQ=test&page[offset]=20are handled correctly.Additional tests are run wich test correct and malformed queries,
seeIssue 6.The return status of the tests is zero if all tests passed, otherwise a positive number.Development ProcessThe idea is stated in themotivation 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.Have a look at the specification:TheSearch APIdescribes how to request a search.TheResponse Schemadescribes what to expect as a response.TheError Schemadescribes what an error should look like.The specification is the most important document.
It determines what needs to be tested.Implement tests according to examples of the specification.
These tests are located in theschul_cloud_search_tests/testsfolder.
They test how you would like to have the search proxy respond to the
different valid and invalid requests.Make the tests run.If it is a new condition under which a proxy request succeeds or fails,
you should implement these as tests in theschul_cloud_search_tests/search_testsfolder.
These tests are executed when a search request goes through the proxy.If this is a communication feature of the proxy, it must be described in
theSpecificationsection.
The code in theschul_cloud_search_tests/proxy.pyshould be touched.Further ReadingReadme Driven DevelopmentYou can edit this documenton Githuband check it withthis editor.