Esempio n. 1
0
 def test_abort_benchmark(self):
     c = BaseClient()
     c.abort_benchmark(
         name = 'test',
         callback = self.handle_cb,
     )
     self.wait()
Esempio n. 2
0
    def test_mtermvector(self):
        c = BaseClient()
        body = """
        {
            "docs": [
                {
                    "_index": "testidx",
                    "_type": "test",
                    "_id": "2",
                    "term_statistics": true
                },
                {
                   "_index": "testidx",
                   "_type": "test",
                   "_id": "1",
                   "fields": [
                       "text"
                   ]
                }
            ]
        }

        """
        c.mtermvectors(
            index = 'index',
            doc_type = 'index',
            body = body,
            callback=self.handle_cb,
        )
        self.wait()
Esempio n. 3
0
 def test_put_template(self):
     c = BaseClient()
     c.put_template(
         'temp123',
         '{"template":"test123"}',
         callback = self.handle_cb,
     )
     self.wait()
Esempio n. 4
0
 def test_search_template(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 404, 403,]}
     )
     c.search_template(index='test', doc_type='test', callback=h_cb)
     self.wait()
Esempio n. 5
0
 def test_doc_exists(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 403, 404]}
     )
     c.doc_exists('test', 'test123', callback=h_cb)
     self.wait()
Esempio n. 6
0
 def test_get_source(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 403, 404]}
     )
     c.get_source('test', 'test123', callback=h_cb)
     self.wait()
Esempio n. 7
0
 def test_clear_scroll(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 403, 404]}
     )
     c.clear_scroll('aaaaa', callback=h_cb)
     self.wait()
Esempio n. 8
0
 def test_index_doc(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 403, 404]}
     )
     c.index_doc('test', 'test', '{"test":"123"}', doc_id='test123',
             callback=h_cb)
     self.wait()
Esempio n. 9
0
 def test_get_template(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[404]}
     )
     c.get_template(
         'temp123',
         callback = h_cb,
     )
     self.wait()
Esempio n. 10
0
 def test_list_benchmarks(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 404]}
     )
     c.list_benchmarks(
         index = 'test',
         callback=h_cb,
     )
     self.wait()
Esempio n. 11
0
 def test_delete_template(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[404]}
     )
     c.delete_template(
         temp_id='temp123',
         callback = h_cb,
     )
     self.wait()
Esempio n. 12
0
 def test_delete_script(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[404]}
     )
     c.delete_script(
         'native',
         'testscript123',
         callback = h_cb,
     )
     self.wait()
Esempio n. 13
0
 def test_count_percolate(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[403, 404]}
     )
     c.count_percolate(
         'test',
         'test',
         callback=h_cb
     )
     self.wait()
Esempio n. 14
0
 def test_mlt(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 404]}
     )
     c.mlt(
         'index',
         'index',
         'bulk1',
         callback=h_cb,
     )
     self.wait()
Esempio n. 15
0
 def test_mpercolate(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 403, 404]}
     )
     c.mpercolate(
         None,
         index='test',
         doc_type='test',
         callback=h_cb
     )
     self.wait()
Esempio n. 16
0
 def test_doc_count(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[403, 404]}
     )
     c.doc_count(
         body     = '',
         index    = 'test',
         doc_type = 'test',
         callback=h_cb
     )
     self.wait()
Esempio n. 17
0
 def test_delete_by_query(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 403, 404]}
     )
     p = {}
     p['source'] = '{ "query": { "match_all": {} } }\n'
     c.delete_by_query(
         'test',
         body='{ "query": { "match_all": {} } }\n',
         doc_type='test',
         params=p,
         callback=h_cb
     )
     self.wait()
Esempio n. 18
0
    def test_explain(self):
        c = BaseClient()
        body = """
        {
            "query" : {
                "term" : { "message" : "search" }
            }
        }

        """
        h_cb = partial(
            self.handle_cb,
            **{'codes':[400, 401, 403, 404]}
        )
        c.explain('test', 'test', 'test123', body=body, callback=h_cb)
        self.wait()
Esempio n. 19
0
    def test_update_doc(self):
        c = BaseClient()
        h_cb = partial(
            self.handle_cb,
            **{'codes':[400, 404, 403,]}
        )
        body = """
        {
            "script" : "ctx._source.counter += count",
            "params" : {
                "count" : 4
            }
        }

        """
        c.update_doc('test', 'test', 'test123', body=body, callback=h_cb)
        self.wait()
Esempio n. 20
0
    def test_bulk(self):
        c = BaseClient()
        h_cb = partial(
            self.handle_cb,
            **{'codes':[400, 404]}
        )
        body = """
        { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
        { "field1" : "value1" }

        """
        c.bulk(
            body,
            index    = 'test',
            doc_type = 'test',
            callback=h_cb
        )
        self.wait()
Esempio n. 21
0
    def test_benchmark(self):
        c = BaseClient()
        body = '''{
            "name": "my_benchmark",
            "competitors": [ {
                "name": "my_competitor",
                "requests": [ {
                    "query": {
                        "match": { "_all": "a*" }
                    }
                } ]
             } ]
        }

        '''
        c.benchmark(
            body     = body,
            index    = 'index',
            doc_type = 'index',
            callback = self.handle_cb,
        )
        self.wait()
Esempio n. 22
0
    def test_suggest(self):
        c = BaseClient()
        h_cb = partial(
            self.handle_cb,
            **{'codes':[400, 403, 404]}
        )
        body = """
        {
            "my-suggestion" : {
                "text" : "the amsterdma meetpu",
                "term" : {
                    "field" : "body"
                }
            }
        }

        """
        c.suggest(
            body,
            index    = 'test',
            callback = h_cb
        )
        self.wait()
Esempio n. 23
0
    def test_put_script(self):
        c = BaseClient()
        body = """
        {
            "query": {
                "function_score": {
                    "query": {
                        "match": {
                             "body": "foo"
                        }
                     },
                    "functions": [
                    {
                        "script_score": {
                            "script": "calculate-score",
                            "params": {
                                "my_modifier": 8
                            }
                        }
                    }
                    ]
                }
            }
        }

        """
        h_cb = partial(
            self.handle_cb,
            **{'codes':[400, 404]}
        )
        c.put_script(
            'native',
            'testscript123',
            body,
            callback = h_cb,
        )
        self.wait()
Esempio n. 24
0
 def test_mget(self):
     c = BaseClient()
     h_cb = partial(
         self.handle_cb,
         **{'codes':[400, 404, 500]}
     )
     body = '''
     {
       "docs" : [
       {
       "_index" : "test",
       "_type" : "type",
       "_id" : "1"
       },
       {
       "_index" : "test",
       "_type" : "type",
       "_id" : "2"
       }
     ]
     }
     '''
     c.mget(body, index='test', doc_type='test', callback=h_cb)
     self.wait()
Esempio n. 25
0
    def test_termvector(self):
        c = BaseClient()
        h_cb = partial(
            self.handle_cb,
            **{'codes':[500, 404]}
        )
        body = """
        {
            "fields" : ["text", "some_field_without_term_vectors"],
                "offsets" : true,
                "positions" : true,
                "term_statistics" : true,
                "field_statistics" : true
        }

        """
        c.termvector(
            'index',
            'test',
            'test123',
            body=body,
            callback=h_cb,
        )
        self.wait()
Esempio n. 26
0
 def test_mk_req(self):
     c = BaseClient()
     # making a req for async http client should work
     self.assertEquals(c.base_url, c.mk_req('').url)
     self.assertEquals('GET', c.mk_req('').method)
Esempio n. 27
0
 def test_mk_url(self):
     c = BaseClient()
     # test making urls
     url = c.mk_url(*['a','b','c'], **{'key':'value'})
     self.assertEquals('/a/b/c?key=value', url)
Esempio n. 28
0
 def test_ping(self):
     c = BaseClient()
     c.ping(callback=self.handle_cb)
     self.wait()
Esempio n. 29
0
 def test_info(self):
     c = BaseClient()
     c.info(callback=self.handle_cb)
     self.wait()