How to use Eve - 10 common examples

To help you get started, we’ve selected a few Eve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MongoEngine / eve-mongoengine / tests / test_patch.py View on Github external
def wrapper(self):
        payload = '{"i": {"a": "hello"}, "d": {"x": null}, "l": ["m", "n"], '+\
                  '"o": [{"a":"hi"},{"b":9}], "p": [{"ll": ["q", "w"]}]}'
        response = self.client.post('/complexdoc/',
                                    data=payload,
                                    content_type='application/json')
        json_data = response.get_json()
        self._id = json_data[config.ID_FIELD]
        self.url = '/complexdoc/%s' % json_data[config.ID_FIELD]
        self.etag = json_data[config.ETAG]
        # check if etags are okay
        self.assertEqual(self.client.get(self.url).get_json()[config.ETAG], self.etag)
        #self._id = response[config.ID_FIELD]
        self.updated = json_data[config.LAST_UPDATED]
        try:
            f(self)
        finally:
            ComplexDoc.objects().delete()
    return wrapper
github MongoEngine / eve-mongoengine / tests / __init__.py View on Github external
def setUpClass(cls):
        SETTINGS['DOMAIN'] = {'eve-mongoengine':{}}
        app = Eve(settings=SETTINGS)
        app.debug = True
        ext = EveMongoengine(app)
        ext.add_model([SimpleDoc, ComplexDoc, LimitedDoc, FieldsDoc,
                       NonStructuredDoc, Inherited, HawkeyDoc])
        cls.ext = ext
        cls.client = app.test_client()
        cls.app = app
github dfci / matchminer-api / tests / test_matchminer / __init__.py View on Github external
# create the engine.
        self.cbio = engine.CBioEngine(MONGO_URI,
                                      MONGO_DBNAME,
                                      data_model.match_schema,
                                      muser=MONGO_USERNAME,
                                      mpass=MONGO_PASSWORD,
                                      collection_clinical=COLLECTION_CLINICAL,
                                      collection_genomic=COLLECTION_GENOMIC)

        # setup the database.
        self.setupDB()

        # prepare the app
        self.settings_file = settings_file
        self.app = eve.Eve(settings=self.settings_file,
                           url_converters=url_converters,
                           auth=security.TokenAuth,
                           validator=ConsentValidatorEve)

        # create the test client
        self.test_client = self.app.test_client()

        # set domain.
        self.domain = self.app.config['DOMAIN']

        # register hooks
        self.app = register_hooks(self.app)

        # register blueprints.
        self.app.register_blueprint(blueprint)
github petrjasek / eve-elastic / test / test_elastic.py View on Github external
def test_search_via_source_param_and_with_source_projection(self):
        query = {'query': {'query_string': {'query': 'foo'}}}
        with self.app.app_context():
            self.app.data.insert('items_with_description', [{'uri': 'foo',
                                                             'description': 'This is foo',
                                                             'name': 'foo'}])
            self.app.data.insert('items_with_description', [{'uri': 'bar', 'name': 'bar'}])
            req = ParsedRequest()
            req.args = {'source': json.dumps(query), 'projections': json.dumps(["name"])}
            res = self.app.data.find('items_with_description', req, None)
            self.assertEqual(1, res.count())
            self.assertTrue('description' not in res.docs[0])
            self.assertTrue('name' in res.docs[0])
github petrjasek / eve-elastic / test / test_elastic.py View on Github external
def test_sub_resource_lookup_with_schema_filter(self):
        with self.app.app_context():
            self.app.data.insert('items_with_description', [{'uri': 'foo', 'description': 'test', 'name': 'foo'}])
            req = ParsedRequest()
            req.args = {}
            self.assertEqual(1, self.app.data.find('items_with_description', req, {'name': 'foo'}).count())
            self.assertEqual(0, self.app.data.find('items_with_description', req, {'name': 'bar'}).count())
github petrjasek / eve-elastic / test / test_elastic.py View on Github external
def test_should_highlight(self):
        with self.app.app_context():
            req = ParsedRequest()
            req.args = {'es_highlight': 1}
            self.assertTrue(self.app.data.should_highlight(req))
            req.args = {'es_highlight': '0'}
            self.assertFalse(self.app.data.should_highlight(req))
github petrjasek / eve-elastic / test / test_elastic.py View on Github external
def test_get_projected_fields(self):
        with self.app.app_context():
            req = ParsedRequest()
            req.args = {'projections': json.dumps(["priority", "urgency", "word_count", "slugline", "highlights"])}
            fields = self.app.data.get_projected_fields(req)
            self.assertEqual(fields, "priority,urgency,word_count,slugline,highlights")
github petrjasek / eve-elastic / test / test_elastic.py View on Github external
def test_search_via_source_param(self):
        query = {'query': {'term': {'uri': 'foo'}}}
        with self.app.app_context():
            self.app.data.insert('items', [{'uri': 'foo', 'name': 'foo'}])
            self.app.data.insert('items', [{'uri': 'bar', 'name': 'bar'}])
            req = ParsedRequest()
            req.args = {'source': json.dumps(query)}
            res = self.app.data.find('items', req, None)
            self.assertEqual(1, res.count())
github petrjasek / eve-elastic / test / test_elastic.py View on Github external
def test_elastic_sort_by_score_if_there_is_query(self):
        with self.app.app_context():
            self.app.data.insert('items', [
                {'uri': 'foo', 'name': 'foo bar'},
                {'uri': 'bar', 'name': 'foo bar'}
            ])

        with self.app.test_request_context('/items/'):
            req = parse_request('items')
            req.args = {'q': 'foo'}
            cursor = self.app.data.find('items', req, None)
            self.assertEqual(2, cursor.count())
            self.assertEqual('foo', cursor[0]['uri'])