示例#1
0
 def test_unindex_raises_not_found_exception(self):
     exception = ElasticSearchException(error=404,
                                        status=404,
                                        result={'not found': 'not found'})
     model = Mock()
     model.unindex = Mock(side_effect=exception)
     unindex_objects(model, [1, 2, 3], 'foo')
示例#2
0
def update_search_index(sender, instance, **kwargs):
    if instance.is_complete:
        index_objects.delay(sender, [instance.id], public=False)
        if instance.is_public_indexable:
            index_objects.delay(sender, [instance.id], public_index=True)
        else:
            unindex_objects(UserProfile, [instance.id], public_index=True)
示例#3
0
 def test_unindex_objects(self, get_es_mock):
     model = MagicMock()
     unindex_objects(model, [1, 2, 3], 'foo')
     ok_(model.unindex.called)
     model.assert_has_calls([
         call.unindex(es=get_es_mock(), public_index='foo', id=1),
         call.unindex(es=get_es_mock(), public_index='foo', id=2),
         call.unindex(es=get_es_mock(), public_index='foo', id=3)])
示例#4
0
 def test_unindex_objects(self, get_es_mock):
     mapping_type = MagicMock()
     unindex_objects(mapping_type, [1, 2, 3], 'foo')
     ok_(mapping_type.unindex.called)
     mapping_type.assert_has_calls([
         call.unindex(1, es=get_es_mock(), public_index='foo'),
         call.unindex(2, es=get_es_mock(), public_index='foo'),
         call.unindex(3, es=get_es_mock(), public_index='foo')])
示例#5
0
 def test_unindex_objects(self, get_es_mock):
     mapping_type = MagicMock()
     unindex_objects(mapping_type, [1, 2, 3], 'foo')
     ok_(mapping_type.unindex.called)
     mapping_type.assert_has_calls([
         call.unindex(1, es=get_es_mock(), public_index='foo'),
         call.unindex(2, es=get_es_mock(), public_index='foo'),
         call.unindex(3, es=get_es_mock(), public_index='foo')])
示例#6
0
 def test_unindex_objects(self, get_es_mock):
     model = MagicMock()
     unindex_objects(model, [1, 2, 3], 'foo')
     ok_(model.unindex.called)
     model.assert_has_calls([
         call.unindex(es=get_es_mock(), public_index='foo', id=1),
         call.unindex(es=get_es_mock(), public_index='foo', id=2),
         call.unindex(es=get_es_mock(), public_index='foo', id=3)
     ])
示例#7
0
 def test_unindex_raises_not_found_exception(self):
     exception = ElasticSearchException(error=404, status=404, result={"not found": "not found"})
     model = Mock()
     model.unindex = Mock(side_effect=exception)
     unindex_objects(model, [1, 2, 3], "foo")
示例#8
0
 def test_unindex_raises_not_found_exception(self):
     exception = NotFoundError(404, {'not found': 'not found '}, {'foo': 'foo'})
     mapping_type = Mock()
     mapping_type.unindex(side_effect=exception)
     unindex_objects(mapping_type, [1, 2, 3], 'foo')
示例#9
0
def remove_from_search_index(sender, instance, **kwargs):
    unindex_objects(UserProfile, [instance.id], public_index=False)
    unindex_objects(UserProfile, [instance.id], public_index=True)
示例#10
0
 def test_unindex_raises_not_found_exception(self):
     exception = NotFoundError(404, {'not found': 'not found '}, {'foo': 'foo'})
     mapping_type = Mock()
     mapping_type.unindex(side_effect=exception)
     unindex_objects(mapping_type, [1, 2, 3], 'foo')