search.controllers.advanced.tests module

Tests for advanced search controller, search.controllers.advanced.

class search.controllers.advanced.tests.TestAdvancedSearchForm(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for AdvancedSearchForm.

test_date_range_must_be_specified()[source]

If the user selects date range, they must indicate start or end.

test_date_range_supports_variable_precision()[source]

Date range in advanced search should support variable precision.

test_end_date_bounding()[source]

If a user selects an end date, it must be bounded correctly.

test_input_whitespace_is_stripped()[source]

If query has padding whitespace, it should be removed.

test_querystring_has_unbalanced_quotes()[source]

Querystring has an odd number of quote characters.

test_single_field_term()[source]

User has entered a single term for a field-based search.

test_specific_year_must_be_specified()[source]

If the user selects specific year, they must indicate a year.

test_term_starts_with_wildcard()[source]

User has entered a string that starts with a wildcard.

test_year_must_be_after_1990()[source]

If the user selects a specific year, it must be after 1990.

class search.controllers.advanced.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 term.

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.advanced.tests.TestMultiFormatDateField(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests the MultiFormatDateField.

test_process_with_one_format()[source]

One date format is specified.

test_process_with_several_formats()[source]

Several date formats are specified.

test_value_with_one_format()[source]

One date format is specified.

class search.controllers.advanced.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.advanced.tests.TestSearchController(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for advanced.search().

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 and advanced param are present.

class search.controllers.advanced.tests.TestUpdateQueryWithDates(methodName='runTest')[source]

Bases: unittest.case.TestCase

advanced._update_query_with_dates() applies date selections.

test_all_dates_is_selected()[source]

Query does not select on date.

test_date_range_is_selected()[source]

Start and end dates are set based on selection.

test_past_12_is_selected()[source]

Query selects the past twelve months.

test_specific_year_is_selected()[source]

Start and end dates are set, one year apart.

class search.controllers.advanced.tests.TestUpdateQueryWithFieldedTerms(methodName='runTest')[source]

Bases: unittest.case.TestCase

advanced._update_query_with_terms() adds primary search terms.

test_multiple_terms_are_provided()[source]

Selected terms are added to the query.

test_multiple_terms_are_provided_with_all_field()[source]

Selected terms are added to the query.

test_terms_are_provided()[source]

Selected terms are added to the query.

class search.controllers.advanced.tests.TestUpdatequeryWithClassification(methodName='runTest')[source]

Bases: unittest.case.TestCase

advanced._update_query_with_classification() adds classfnxn.

test_classification_is_selected()[source]

Selected classifications are added to the query.

test_multiple_classifications_are_selected()[source]

Selected classifications are added to the query.

test_physics_is_selected_all_archives()[source]

The physics group is added to the query.

test_physics_is_selected_specific_archive()[source]

The physic group and specified archive are added to the query.

test_physics_is_selected_specific_archive_plus_other_groups()[source]

The physics group and specified archive are added to the query.