예제 #1
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document(self):
        connection = manager.get_connection()

        connection.update(Index2, {"id": "1", "content": "Kaka"})

        response = connection.search("Kaka", index=Index2)
        self.assertEqual(len(response), 1)
예제 #2
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document(self):
        connection = manager.get_connection()

        connection.update(Index2, {"id": "1", "content": "Kaka"})

        response = connection.search("Kaka", index=Index2)
        self.assertEqual(len(response), 1)
예제 #3
0
    def test_create_destroy_index(self):
        connection = manager.get_connection()
        connection.create_index(Index1)

        with self.assertRaises(exceptions.IndexAlreadyExists):
            connection.create_index(Index1)

        connection.delete_index(Index1)
예제 #4
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_create_destroy_index(self):
        connection = manager.get_connection()
        connection.create_index(Index1)

        with self.assertRaises(exceptions.IndexAlreadyExists):
            connection.create_index(Index1)

        connection.delete_index(Index1)
예제 #5
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_update_document(self):
        connection = manager.get_connection()

        connection.update("index2", {"id": "1", "content": "Kaka1"})
        connection.update("index2", {"id": "1", "content": "Kaka2"})
        response = connection.search("*", index="index2")

        self.assertEqual(len(response), 1)
        self.assertEqual(response.items[0].data["content"], "Kaka2")
예제 #6
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_with_custom_parser_01(self):
        parser = qparser.QueryParser("text", Index3.get_schema())
        doc = self._create_document(id=1)

        connection = manager.get_connection()
        connection.update("index3", doc)

        result = connection.search("speci", index="index3", parser=parser)
        self.assertEqual(len(result), 1)
예제 #7
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_with_custom_parser_01(self):
        parser = qparser.QueryParser("text", Index3.get_schema())
        doc = self._create_document(id=1)

        connection = manager.get_connection()
        connection.update("index3", doc)

        result = connection.search("speci", index="index3", parser=parser)
        self.assertEqual(len(result), 1)
예제 #8
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_update_document(self):
        connection = manager.get_connection()

        connection.update("index2", {"id": "1", "content": "Kaka1"})
        connection.update("index2", {"id": "1", "content": "Kaka2"})
        response = connection.search("*", index="index2")

        self.assertEqual(len(response), 1)
        self.assertEqual(response.items[0].data["content"], "Kaka2")
예제 #9
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document(self):
        connection = manager.get_connection()

        connection.update(Index2, {"id": "1", "content": "Kaka"})
        connection.refresh(Index2)

        response = connection.search({"query": {"match_all":{}}}, index=Index2)

        self.assertIsInstance(response, result.SearchResult)
        self.assertEqual(len(response), 1)
예제 #10
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_match_all_with_slicing(self):
        connection = manager.get_connection()

        for i in range(30):
            doc = {"id": "foo.{0}".format(i), "content": "kaka-{0}".format(i)}
            connection.update(Index2, doc)

        connection.refresh(Index2)

        response = connection.search({"query":{"match_all":{}}},  size=2, index=Index2)
        self.assertEqual(len(response), 2)
        self.assertEqual(response.total_results, 30)
예제 #11
0
    def test_index_document(self):
        connection = manager.get_connection()

        connection.update(Index2, {"id": "1", "content": "Kaka"})
        connection.refresh(Index2)

        response = connection.search({"query": {
            "match_all": {}
        }},
                                     index=Index2)

        self.assertIsInstance(response, result.SearchResult)
        self.assertEqual(len(response), 1)
예제 #12
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_01(self):
        doc = self._create_document(id=1)

        connection = manager.get_connection()
        connection.update("index3", doc)

        result = connection.search("Kaka", index="index3")
        self.assertEqual(len(result), 0)

        result = connection.search("this is", index="index3")
        self.assertEqual(len(result), 0)

        result = connection.search("speci", index="index3")
        self.assertEqual(len(result), 1)
예제 #13
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_01(self):
        doc = self._create_document(id=1)

        connection = manager.get_connection()
        connection.update("index3", doc)

        result = connection.search("Kaka", index="index3")
        self.assertEqual(len(result), 0)

        result = connection.search("this is", index="index3")
        self.assertEqual(len(result), 0)

        result = connection.search("speci", index="index3")
        self.assertEqual(len(result), 1)
예제 #14
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_with_custom_parser_03(self):
        parser = qparser.QueryParser("tags", Index3.get_schema())

        doc1 = self._create_document(id=1)
        doc2 = self._create_document(id=2)

        connection = manager.get_connection()
        connection.update("index3", doc1)
        connection.update("index3", doc2)

        result = connection.search("foo1", index="index3", parser=parser)
        self.assertEqual(len(result), 1)

        result = connection.search("foo1 OR bar2", index="index3", parser=parser)
        self.assertEqual(len(result), 2)
예제 #15
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_with_custom_parser_02(self):
        parser = qparser.QueryParser("number", Index3.get_schema())

        doc1 = self._create_document(id=1)
        doc2 = self._create_document(id=2)

        connection = manager.get_connection()
        connection.update("index3", doc1)
        connection.update("index3", doc2)

        result = connection.search("2", index="index3", parser=parser)
        self.assertEqual(len(result), 1)

        result = connection.search("2 OR 3", index="index3", parser=parser)
        self.assertEqual(len(result), 2)
예제 #16
0
    def test_match_all_with_slicing(self):
        connection = manager.get_connection()

        for i in range(30):
            doc = {"id": "foo.{0}".format(i), "content": "kaka-{0}".format(i)}
            connection.update(Index2, doc)

        connection.refresh(Index2)

        response = connection.search({"query": {
            "match_all": {}
        }},
                                     size=2,
                                     index=Index2)
        self.assertEqual(len(response), 2)
        self.assertEqual(response.total_results, 30)
예제 #17
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_get_default_connection_twice(self):
        connection1 = manager.get_connection()
        connection2 = manager.get_connection()

        self.assertEqual(connection1, connection2)
예제 #18
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_get_default_connection(self):
        from needlestack.whoosh.base import Whoosh
        connection = manager.get_connection("default")

        self.assertIsInstance(connection, Whoosh)
예제 #19
0
파일: tests.py 프로젝트: niwinz/needlestack
 def setUp(self):
     connection = manager.get_connection()
     connection.delete_all_indexes()
     connection.create_index(Index3)
예제 #20
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_get_default_connection(self):
        from needlestack.whoosh.base import Whoosh
        connection = manager.get_connection("default")

        self.assertIsInstance(connection, Whoosh)
예제 #21
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_using_string_resolve(self):
        connection = manager.get_connection()
        connection.update("index2", {"id": "1", "content": "Kaka"})

        response = connection.search("Kaka", index="index2")
        self.assertEqual(len(response), 1)
예제 #22
0
파일: tests.py 프로젝트: niwinz/needlestack
 def tearDown(self):
     connection = manager.get_connection()
     connection.delete_all_indexes()
예제 #23
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_get_inexistent_connection(self):
        from django.core.exceptions import ImproperlyConfigured

        with self.assertRaises(ImproperlyConfigured):
            connection = manager.get_connection("inexistent")
예제 #24
0
    def test_get_inexistent_connection(self):
        from django.core.exceptions import ImproperlyConfigured

        with self.assertRaises(ImproperlyConfigured):
            connection = manager.get_connection("inexistent")
예제 #25
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_get_default_connection(self):
        from needlestack.elasticsearch.base import ElasticSearch
        connection = manager.get_connection("default")

        self.assertIsInstance(connection, ElasticSearch)
예제 #26
0
    def test_get_default_connection(self):
        from needlestack.elasticsearch.base import ElasticSearch
        connection = manager.get_connection("default")

        self.assertIsInstance(connection, ElasticSearch)
예제 #27
0
파일: tests.py 프로젝트: niwinz/needlestack
    def test_index_document_using_string_resolve(self):
        connection = manager.get_connection()
        connection.update("index2", {"id": "1", "content": "Kaka"})

        response = connection.search("Kaka", index="index2")
        self.assertEqual(len(response), 1)
예제 #28
0
파일: tests.py 프로젝트: niwinz/needlestack
 def setUp(self):
     connection = manager.get_connection()
     connection.delete_all_indexes()
     connection.create_index(Index2)
예제 #29
0
 def setUp(self):
     connection = manager.get_connection()
     connection.create_index(Index2)
예제 #30
0
파일: tests.py 프로젝트: niwinz/needlestack
 def tearDown(self):
     connection = manager.get_connection()
     connection.delete_index(Index2)
예제 #31
0
 def tearDown(self):
     connection = manager.get_connection()
     connection.delete_index(Index2)
예제 #32
0
    def test_get_default_connection_twice(self):
        connection1 = manager.get_connection()
        connection2 = manager.get_connection()

        self.assertEqual(connection1, connection2)
예제 #33
0
파일: tests.py 프로젝트: niwinz/needlestack
 def tearDown(self):
     connection = manager.get_connection()
     connection.delete_all_indexes()