def setUpClass(cls): super(QueryTest, cls).setUpClass() if cls.skip_tests: return index = FakeDjangoMappingType.get_index() doctype = FakeDjangoMappingType.get_mapping_type_name() cls.create_index(index) data = [ {'id': 1, 'foo': 'bar', 'tag': 'awesome', 'width': '2'}, {'id': 2, 'foo': 'bart', 'tag': 'boring', 'width': '7'}, {'id': 3, 'foo': 'car', 'tag': 'awesome', 'width': '5'}, {'id': 4, 'foo': 'duck', 'tag': 'boat', 'width': '11'}, {'id': 5, 'foo': 'train car', 'tag': 'awesome', 'width': '7'} ] cls.index_data(data, index=index, doctype=doctype) # Generate all the FakeModels in our "database" for args in data: FakeModel(**args) cls.refresh(index)
def persist_data(self, data): for doc in data: FakeModel(**doc) # Index the document with .index() FakeDjangoMappingType.index(doc, id_=doc['id']) self.refresh(FakeDjangoMappingType.get_index())
def persist_data(self, data): for doc in data: FakeModel(**doc) # Index the document with .index() FakeDjangoMappingType.index(doc, id_=doc["id"]) self.refresh(FakeDjangoMappingType.get_index())
def test_index(self): document = {'id': 1, 'name': 'odin skullcrusher'} # Generate the FakeModel in our "database" FakeModel(**document) # Index the document with .index() FakeDjangoMappingType.index(document, id_=document['id']) self.refresh(FakeDjangoMappingType.get_index()) # Query it to make sure it's there. eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1)
def setUpClass(cls): super(QueryTest, cls).setUpClass() if cls.skip_tests: return index = FakeDjangoMappingType.get_index() doctype = FakeDjangoMappingType.get_mapping_type_name() cls.create_index(index) data = [{ 'id': 1, 'foo': 'bar', 'tag': 'awesome', 'width': '2' }, { 'id': 2, 'foo': 'bart', 'tag': 'boring', 'width': '7' }, { 'id': 3, 'foo': 'car', 'tag': 'awesome', 'width': '5' }, { 'id': 4, 'foo': 'duck', 'tag': 'boat', 'width': '11' }, { 'id': 5, 'foo': 'train car', 'tag': 'awesome', 'width': '7' }] cls.index_data(data, index=index, doctype=doctype) # Generate all the FakeModels in our "database" for args in data: FakeModel(**args) cls.refresh(index)
def test_bulk_index(self): documents = [ {'id': 1, 'name': 'odin skullcrusher'}, {'id': 2, 'name': 'heimdall kneebiter'}, {'id': 3, 'name': 'erik rose'} ] # Generate the FakeModel in our "database" for doc in documents: FakeModel(**doc) # Index the document with .index() FakeDjangoMappingType.bulk_index(documents, id_field='id') self.refresh(FakeDjangoMappingType.get_index()) # Query it to make sure they're there. eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1) eq_(len(S(FakeDjangoMappingType).query(name__prefix='erik')), 1)
def test_bulk_index(self): documents = [ {"id": 1, "name": "odin skullcrusher"}, {"id": 2, "name": "heimdall kneebiter"}, {"id": 3, "name": "erik rose"}, ] # Generate the FakeModel in our "database" for doc in documents: FakeModel(**doc) # Index the document with .index() FakeDjangoMappingType.bulk_index(documents, id_field="id") self.refresh(FakeDjangoMappingType.get_index()) # Query it to make sure they're there. eq_(len(S(FakeDjangoMappingType).query(name__prefix="odin")), 1) eq_(len(S(FakeDjangoMappingType).query(name__prefix="erik")), 1)
def test_bulk_index(self): documents = [{ 'id': 1, 'name': 'odin skullcrusher' }, { 'id': 2, 'name': 'heimdall kneebiter' }, { 'id': 3, 'name': 'erik rose' }] # Generate the FakeModel in our "database" for doc in documents: FakeModel(**doc) # Index the document with .index() FakeDjangoMappingType.bulk_index(documents, id_field='id') self.refresh(FakeDjangoMappingType.get_index()) # Query it to make sure they're there. eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1) eq_(len(S(FakeDjangoMappingType).query(name__prefix='erik')), 1)
def tearDown(self): super(TestTasks, self).tearDown() TestTasks.cleanup_index(FakeDjangoMappingType.get_index())
def setUp(self): super(TestTasks, self).setUp() TestTasks.create_index(FakeDjangoMappingType.get_index()) reset_model_cache()
def setUp(self): super(IndexableTest, self).setUp() IndexableTest.create_index(FakeDjangoMappingType.get_index())
def tearDown(self): super(IndexableTest, self).tearDown() IndexableTest.cleanup_index(FakeDjangoMappingType.get_index()) reset_model_cache()
def tearDown(self): super(IndexableTest, self).tearDown() IndexableTest.cleanup_index(FakeDjangoMappingType.get_index())