<s> from __future__ import absolute_import , unicode_literals <EOL> from django . test import TestCase <EOL> from wagtail . tests . search import models <EOL> from wagtail . wagtailsearch import index <EOL> class TestContentTypeNames ( TestCase ) : <EOL> def test_base_content_type_name ( self ) : <EOL> name = models . SearchTestChild . indexed_get_toplevel_content_type ( ) <EOL> self . assertEqual ( name , '<STR_LIT>' ) <EOL> def test_qualified_content_type_name ( self ) : <EOL> name = models . SearchTestChild . indexed_get_content_type ( ) <EOL> self . assertEqual ( name , '<STR_LIT>' ) <EOL> class TestSearchFields ( TestCase ) : <EOL> def make_dummy_type ( self , search_fields ) : <EOL> return type ( str ( '<STR_LIT>' ) , ( index . Indexed , ) , dict ( search_fields = search_fields ) ) <EOL> def test_basic ( self ) : <EOL> cls = self . make_dummy_type ( [ <EOL> index . SearchField ( '<STR_LIT:test>' , boost = <NUM_LIT:100> , partial_match = False ) , <EOL> index . FilterField ( '<STR_LIT>' ) , <EOL> ] ) <EOL> self . assertEqual ( len ( cls . get_search_fields ( ) ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( cls . get_searchable_search_fields ( ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( cls . get_filterable_search_fields ( ) ) , <NUM_LIT:1> ) <EOL> def test_overriding ( self ) : <EOL> cls = self . make_dummy_type ( [ <EOL> index . SearchField ( '<STR_LIT:test>' , boost = <NUM_LIT:100> , partial_match = False ) , <EOL> index . SearchField ( '<STR_LIT:test>' , partial_match = True ) , <EOL> ] ) <EOL> self . assertEqual ( len ( cls . get_search_fields ( ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( cls . get_searchable_search_fields ( ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( cls . get_filterable_search_fields ( ) ) , <NUM_LIT:0> ) <EOL> field = cls . get_search_fields ( ) [ <NUM_LIT:0> ] <EOL> self . assertIsInstance ( field , index . SearchField ) <EOL> self . assertIsNone ( field . boost ) <EOL> self . assertTrue ( field . partial_match ) <EOL> def test_different_field_types_dont_override ( self ) : <EOL> cls = self . make_dummy_type ( [ <EOL> index . SearchField ( '<STR_LIT:test>' , boost = <NUM_LIT:100> , partial_match = False ) , <EOL> index . FilterField ( '<STR_LIT:test>' ) , <EOL> ] ) <EOL> self . assertEqual ( len ( cls . get_search_fields ( ) ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( cls . get_searchable_search_fields ( ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( cls . get_filterable_search_fields ( ) ) , <NUM_LIT:1> ) </s>
