search.controllers.simple.tests module

Tests for simple search controller, search.controllers.simple.

class search.controllers.simple.tests.TestClassicAuthorSyntaxIsIntercepted(methodName='runTest')[source]

Bases: unittest.case.TestCase

The user may have entered an author query using surname_f syntax.

This is an artefact of the classic search system, and not intended to be supported. Nevertheless, users have become accustomed to this syntax. We therefore rewrite the query using a comma, and show the user a warning about the syntax change.

test_all_fields_search_contains_classic_syntax(mock_index)[source]

User has entered a surname_f query in an all-fields search.

test_all_fields_search_multiple_classic_syntax(mock_index)[source]

User has entered a classic query with multiple authors.

test_author_search_contains_classic_syntax(mock_index)[source]

User has entered a surname_f query in an author search.

test_title_search_contains_classic_syntax(mock_index)[source]

User has entered a surname_f query in a title search.

class search.controllers.simple.tests.TestPaginationParametersAreFunky(methodName='runTest')[source]

Bases: unittest.case.TestCase

The user may have monkeyed with the order or sort parameters.

Since these are limited to specific values, there is no other reason for them to be invalid. Given that they are passed around among views (to persist users’ selection), it’s important to break the chain. To do this, we return a 400 Bad Request, with a clean link back to the search form.

test_order_is_invalid(mock_url_for)[source]

The order parameter on the request is invalid.

test_size_is_invalid(mock_url_for)[source]

The order parameter on the request is invalid.

class search.controllers.simple.tests.TestQueryFromForm(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for simple._query_from_form().

test_form_data_has_no_order()[source]

Form data includes sort order parameter, but it is ‘None’.

test_form_data_has_order()[source]

Form data includes sort order.

test_input_whitespace_is_stripped()[source]

If query has padding whitespace, it should be removed.

test_multiple_simple()[source]

Form data has three simple.

test_querystring_has_unbalanced_quotes()[source]

Querystring has an odd number of quote characters.

test_querystring_has_wildcard_at_start()[source]

Querystring starts with a wildcard.

class search.controllers.simple.tests.TestRetrieveDocument(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for simple.retrieve_document().

test_document_not_found(mock_index)[source]

The document is not found.

test_encounters_queryerror(mock_index)[source]

There is a bug in the index or query.

test_index_raises_connection_exception(mock_index)[source]

Index service raises a IndexConnectionError.

class search.controllers.simple.tests.TestSearchController(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for simple.search().

test_arxiv_id(mock_index)[source]

Query parameter contains an arXiv ID.

test_index_raises_connection_exception(mock_index)[source]

Index service raises a IndexConnectionError.

test_index_raises_query_error(mock_index)[source]

Index service raises a QueryError.

test_invalid_data(mock_index)[source]

Form data are invalid.

test_no_form_data(mock_index)[source]

No form data has been submitted.

test_single_field_term(mock_index)[source]

Form data are present.

class search.controllers.simple.tests.TestSimpleSearchForm(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for SimpleSearchForm.

test_query_and_searchtype()[source]

User has entered a searchtype (field) and query (value).

test_query_only()[source]

User has entered only a query (value); this should never happen.

test_searchtype_only()[source]

User has entered only a searchtype (field).