예제 #1
0
    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'])

        IndexableTest.refresh()

        # Query it to make sure it's there.
        eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1)
예제 #2
0
    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'])

        IndexableTest.refresh()

        # Query it to make sure it's there.
        eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1)
예제 #3
0
    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')

        IndexableTest.refresh()

        # 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)
예제 #4
0
    def setup_class(cls):
        if cls.skip_tests or SKIP_TESTS:
            return

        super(QueryTest, cls).setup_class()

        cls.create_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=FakeDjangoMappingType.get_index(),
                       doctype=FakeDjangoMappingType.get_mapping_type_name())

        # Generate all the FakeModels in our "database"
        for args in data:
            FakeModel(**args)

        cls.refresh()
예제 #5
0
    def setup_class(cls):
        super(QueryTest, cls).setup_class()
        if cls.skip_tests or SKIP_TESTS:
            return

        cls.create_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=FakeDjangoMappingType.get_index(), doctype=FakeDjangoMappingType.get_mapping_type_name()
        )

        # Generate all the FakeModels in our "database"
        for args in data:
            FakeModel(**args)

        cls.refresh()
예제 #6
0
    def setup_class(cls):
        super(QueryTest, cls).setup_class()
        if cls.skip_tests or SKIP_TESTS:
            return

        cls.create_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=FakeDjangoMappingType.get_index(),
                       doctype=FakeDjangoMappingType.get_mapping_type_name())

        # Generate all the FakeModels in our "database"
        for args in data:
            FakeModel(**args)

        cls.refresh()
예제 #7
0
    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')

        IndexableTest.refresh()

        # 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)
예제 #8
0
    def test_tasks(self):
        documents = [
            {'id': 1, 'name': 'odin skullcrusher'},
            {'id': 2, 'name': 'heimdall kneebiter'},
            {'id': 3, 'name': 'erik rose'}
            ]

        for doc in documents:
            FakeModel(**doc)

        # Test index_objects task
        index_objects(FakeDjangoMappingType, [1, 2, 3])
        FakeDjangoMappingType.refresh_index()
        eq_(FakeDjangoMappingType.search().count(), 3)

        # Test unindex_objects task
        unindex_objects(FakeDjangoMappingType, [1, 2, 3])
        FakeDjangoMappingType.refresh_index()
        eq_(FakeDjangoMappingType.search().count(), 0)
예제 #9
0
    def test_tasks(self):
        documents = [{
            'id': 1,
            'name': 'odin skullcrusher'
        }, {
            'id': 2,
            'name': 'heimdall kneebiter'
        }, {
            'id': 3,
            'name': 'erik rose'
        }]

        for doc in documents:
            FakeModel(**doc)

        # Test index_objects task
        index_objects(FakeDjangoMappingType, [1, 2, 3])
        FakeDjangoMappingType.refresh_index()
        eq_(FakeDjangoMappingType.search().count(), 3)

        # Test unindex_objects task
        unindex_objects(FakeDjangoMappingType, [1, 2, 3])
        FakeDjangoMappingType.refresh_index()
        eq_(FakeDjangoMappingType.search().count(), 0)
예제 #10
0
 def test_refresh(self):
     FakeDjangoMappingType.refresh_index()
예제 #11
0
 def test_refresh(self):
     FakeDjangoMappingType.refresh_index()