def test_creates_fts_index_by_default(self): connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('_full_text', connection, resource_id)
def test_default_fts_index_method_can_be_overwritten_by_config_var(self): connection = mock.MagicMock() context = {'connection': connection} resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('_full_text', connection, resource_id, method='gin')
def test_default_fts_index_method_can_be_overwritten_by_config_var(self): connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('_full_text', connection, resource_id, method='gin')
def test_creates_fts_index_on_textual_fields_can_overwrite_lang_with_config_var(self, _get_fields): _get_fields.return_value = [ {'id': 'foo', 'type': 'text'}, ] connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('foo', connection, resource_id, 'simple')
def test_creates_fts_index_on_textual_fields_can_overwrite_lang_with_config_var(self, _get_fields): _get_fields.return_value = [ {'id': 'foo', 'type': 'text'}, {'id': 'bar', 'type': 'number'} ] connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('foo', connection, resource_id, 'simple')
def test_creates_fts_index_on_textual_fields_with_english_as_default(self, _get_fields): _get_fields.return_value = [ {'id': 'foo', 'type': 'text'}, {'id': 'bar', 'type': 'number'} ] connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('foo', connection, resource_id, 'english')
def test_creates_fts_index_on_textual_fields_can_overwrite_lang_using_lang_param(self, _get_fields): _get_fields.return_value = [ {'id': 'foo', 'type': 'text'}, {'id': 'bar', 'type': 'number'} ] connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, 'lang': 'french', } db.create_indexes(context, data_dict) self._assert_created_index_on('foo', connection, resource_id, 'french')
def test_creates_fts_index_on_all_fields_except_dates_nested_and_arrays_with_english_as_default( self, _get_fields): _get_fields.return_value = [ { 'id': 'text', 'type': 'text' }, { 'id': 'number', 'type': 'number' }, { 'id': 'nested', 'type': 'nested' }, { 'id': 'date', 'type': 'date' }, { 'id': 'text array', 'type': 'text[]' }, { 'id': 'timestamp', 'type': 'timestamp' }, ] connection = mock.MagicMock() context = {'connection': connection} resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('text', connection, resource_id, 'english') self._assert_created_index_on('number', connection, resource_id, 'english', cast=True)
def test_creates_fts_index_on_textual_fields_can_overwrite_lang_using_lang_param( self, _get_fields): _get_fields.return_value = [ { 'id': 'foo', 'type': 'text' }, ] connection = mock.MagicMock() context = {'connection': connection} resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, 'lang': 'french', } db.create_indexes(context, data_dict) self._assert_created_index_on('foo', connection, resource_id, 'french')
def test_creates_fts_index_on_all_fields_except_dates_nested_and_arrays_with_english_as_default(self, _get_fields): _get_fields.return_value = [ {'id': 'text', 'type': 'text'}, {'id': 'number', 'type': 'number'}, {'id': 'nested', 'type': 'nested'}, {'id': 'date', 'type': 'date'}, {'id': 'text array', 'type': 'text[]'}, {'id': 'timestamp', 'type': 'timestamp'}, ] connection = mock.MagicMock() context = { 'connection': connection } resource_id = 'resource_id' data_dict = { 'resource_id': resource_id, } db.create_indexes(context, data_dict) self._assert_created_index_on('text', connection, resource_id, 'english') self._assert_created_index_on('number', connection, resource_id, 'english', cast=True)