Пример #1
0
    def setup(self):
        es = ElasticSearch()
        es.host = 'http://127.0.1.1:9202'
        es.index = 'foobar'
        self.es = es

        class MyModel(self.es.Model):
            __type__ = 'footype'

        self.Model = MyModel
    def setup(self):
        es = ElasticSearch()
        es.host = 'http://127.0.1.1:9202'
        es.index = 'foobar'
        self.es = es

        class MyModel(self.es.Model):
            __type__ = 'footype'

        self.Model = MyModel
    def setup(self):
        es = ElasticSearch()
        es.host = "http://127.0.1.1:9202"
        es.index = "foobar"
        self.es = es

        class MyModel(self.es.Model):
            __type__ = "footype"

        self.Model = MyModel
Пример #4
0
 def test_conn(self):
     app = Flask('testy')
     app.config['ELASTICSEARCH_HOST'] = 'http://127.0.1.1:9202'
     app.config['ELASTICSEARCH_INDEX'] = 'foobar'
     es = ElasticSearch(app)
     with app.app_context():
         assert_true(isinstance(es.conn, elasticsearch.Elasticsearch))
Пример #5
0
    def test_adds_to_app_extensions(self):
        class App(object):
            name = 'foo'
            config = MagicMock()

        app = App()
        es = ElasticSearch(app)
        assert_equal(app.extensions['elasticsearch'], es)
Пример #6
0
 def test_auth(self):
     app = Flask('testy')
     app.config['ELASTICSEARCH_HOST'] = 'http://*****:*****@127.0.1.1:9202'
     app.config['ELASTICSEARCH_INDEX'] = 'foobar'
     es = ElasticSearch(app)
     with app.app_context():
         assert_equal(('foo', 'bar'),
                      es.conn.transport.hosts[0]['http_auth'])
Пример #7
0
    def setup(self):
        self.app = MagicMock()
        self.es = ElasticSearch(self.app)

        class MyModel(self.es.Model):
            __type__ = 'footype'

        self.Model = MyModel
Пример #8
0
 def test_config(self):
     es = ElasticSearch(
         host='http://127.0.1.1:9202',
         index='foobar',
         authorization_enabled=True,
     )
     assert_equal(es.host, 'http://127.0.1.1:9202')
     assert_equal(es.index, 'foobar')
     assert_equal(es.authorization_enabled, True)
Пример #9
0
    def setup(self):
        app = Flask('testy')
        app.config['ELASTICSEARCH_HOST'] = 'http://127.0.1.1:9202'
        app.config['ELASTICSEARCH_INDEX'] = 'foobar'
        self.es = ElasticSearch(app)

        class MyModel(self.es.Model):
            __type__ = 'footype'

        self.Model = MyModel

        self.ctx = app.app_context()
        self.ctx.push()
Пример #10
0
 def test_index(self):
     app = Flask('testy')
     app.config['ELASTICSEARCH_INDEX'] = 'foobar'
     es = ElasticSearch(app)
     with app.app_context():
         assert_equal(es.index, 'foobar')
Пример #11
0
 def test_init_app(self):
     app = MagicMock()
     es = ElasticSearch()
     es.init_app(app)
     assert_equal(es.app, None)
Пример #12
0
 def test_noapp_error(self):
     es = ElasticSearch()
     assert_raises(RuntimeError, es.get_app)
Пример #13
0
 def test_noapp_error(self):
     es = ElasticSearch()
     assert_raises(RuntimeError, lambda: es.conn)
 def test_init_app(self):
     app = MagicMock()
     es = ElasticSearch()
     es.init_app(app)
     assert_equal(es.app, None)
Пример #15
0
 def test_conn(self):
     es = ElasticSearch()
     es.host = 'http://127.0.1.1:9202'
     es.index = 'foobar'
     assert_true(isinstance(es.conn, elasticsearch.Elasticsearch))
Пример #16
0
 def test_index(self):
     app = MagicMock()
     app.config.__getitem__.return_value = 'foobar'
     es = ElasticSearch(app)
     assert_equal(es.index, 'foobar')
Пример #17
0
 def test_init_creates_model(self):
     es = ElasticSearch()
     assert_equal(es.Model.mro()[1], _Model)
Пример #18
0
 def test_conn(self, pyes_mock):
     app = MagicMock()
     es = ElasticSearch(app)
     assert_equal(es.conn, pyes_mock.return_value)
Пример #19
0
 def test_auth(self):
     es = ElasticSearch()
     es.host = "http://*****:*****@127.0.1.1:9202"
     es.index = "foobar"
     assert_equal(("foo", "bar"), es.conn.transport.hosts[0]["http_auth"])
Пример #20
0
 def test_init_without_app(self):
     es = ElasticSearch()
     assert_equal(es.app, None)
 def test_auth(self):
     es = ElasticSearch()
     es.host = 'http://*****:*****@127.0.1.1:9202'
     es.index = 'foobar'
     assert_equal(('foo', 'bar'),
                  es.conn.transport.hosts[0]['http_auth'])
Пример #22
0
 def test_auth(self):
     es = ElasticSearch()
     es.host = 'http://*****:*****@127.0.1.1:9202'
     es.index = 'foobar'
     assert_equal(('foo', 'bar'), es.conn.transport.hosts[0]['http_auth'])
 def test_conn(self):
     es = ElasticSearch()
     es.host = 'http://127.0.1.1:9202'
     es.index = 'foobar'
     assert_true(isinstance(es.conn, elasticsearch.Elasticsearch))
Пример #24
0
 def test_init_with_app(self):
     app = MagicMock()
     es = ElasticSearch(app)
     assert_equal(es.app, app)