Example #1
0
    def test_custom_datalayer(self):
        class MyTestDataLayer(DataLayer):
            def init_app(self, app):
                pass

        self.app = Eve(data=MyTestDataLayer, settings=self.settings_file)
        self.assertEqual(type(self.app.data), MyTestDataLayer)
Example #2
0
 def test_mongodb_settings(self):
     # Create custom app with mongodb settings.
     settings = {
         'DOMAIN': {
             'contacts': {}
         },
         'MONGO_OPTIONS': {
             'connect': False
         }
     }
     app = Eve(settings=settings)
     # Check if settings are set.
     self.assertEqual(app.config['MONGO_OPTIONS']['connect'],
                      app.config['MONGO_CONNECT'])
     # Prepare a specific schema with mongo specific settings.
     settings = {
         'schema': {
             'name': {
                 'type': 'string'
             },
         },
         'MONGO_OPTIONS': {
             'connect': False
         }
     }
     self.app.register_resource('mongodb_settings', settings)
     # check that settings are set.
     resource_settings = self.app.config['DOMAIN']['mongodb_settings']
     self.assertEqual(resource_settings['MONGO_OPTIONS'],
                      settings['MONGO_OPTIONS'])
     # check that settings are set.
     self.assertEqual(resource_settings['MONGO_OPTIONS']['connect'],
                      settings['MONGO_OPTIONS']['connect'])
Example #3
0
 def test_mongodb_settings(self):
     # Create custom app with mongodb settings.
     settings = {
         "DOMAIN": {
             "contacts": {}
         },
         "MONGO_OPTIONS": {
             "connect": False
         }
     }
     app = Eve(settings=settings)
     # Check if settings are set.
     self.assertEqual(app.config["MONGO_OPTIONS"]["connect"],
                      app.config["MONGO_CONNECT"])
     # Prepare a specific schema with mongo specific settings.
     settings = {
         "schema": {
             "name": {
                 "type": "string"
             }
         },
         "MONGO_OPTIONS": {
             "connect": False
         },
     }
     self.app.register_resource("mongodb_settings", settings)
     # check that settings are set.
     resource_settings = self.app.config["DOMAIN"]["mongodb_settings"]
     self.assertEqual(resource_settings["MONGO_OPTIONS"],
                      settings["MONGO_OPTIONS"])
     # check that settings are set.
     self.assertEqual(
         resource_settings["MONGO_OPTIONS"]["connect"],
         settings["MONGO_OPTIONS"]["connect"],
     )
 def test_allow_unknown_with_soft_delete(self):
     my_settings = {
         'ALLOW_UNKNOWN': True,
         'SOFT_DELETE': True,
         'DOMAIN': {'contacts': {}}
     }
     try:
         self.app = Eve(settings=my_settings)
     except TypeError:
         self.fail("ALLOW_UNKNOWN and SOFT_DELETE enabled should not cause "
                   "a crash.")
Example #5
0
 def test_allow_unknown_with_soft_delete(self):
     my_settings = {
         "ALLOW_UNKNOWN": True,
         "SOFT_DELETE": True,
         "DOMAIN": {"contacts": {}},
     }
     try:
         self.app = Eve(settings=my_settings)
     except TypeError:
         self.fail(
             "ALLOW_UNKNOWN and SOFT_DELETE enabled should not cause " "a crash."
         )
 def test_custom_import_name(self):
     self.app = Eve('unittest', settings=self.settings_file)
     self.assertEqual(self.app.import_name, 'unittest')
 def test_custom_validator(self):
     class MyTestValidator(Validator):
         pass
     self.app = Eve(validator=MyTestValidator,
                    settings=self.settings_file)
     self.assertEqual(self.app.validator, MyTestValidator)
Example #8
0
 def test_existing_env_config(self):
     env = os.environ
     os.environ = {'EVE_SETTINGS': 'test_settings_env.py'}
     self.app = Eve()
     self.assertTrue('env_domain' in self.app.config['DOMAIN'])
     os.environ = env
Example #9
0
File: config.py Project: Tefnet/eve
 def test_custom_import_name(self):
     self.app = Eve('custom_import_name',
                    settings='eve/tests/test_settings.py')
     self.assertEqual(self.app.import_name, 'custom_import_name')
Example #10
0
 def test_custom_kwargs(self):
     self.app = Eve("unittest", static_folder="static/", settings=self.settings_file)
     self.assertTrue(self.app.static_folder.endswith("static"))
Example #11
0
 def test_existing_env_config(self):
     env = os.environ
     os.environ = {"EVE_SETTINGS": "test_settings_env.py"}
     self.app = Eve()
     self.assertTrue("env_domain" in self.app.config["DOMAIN"])
     os.environ = env
Example #12
0
 def test_custom_kwargs(self):
     self.app = Eve("unittest",
                    static_folder="/",
                    settings=self.settings_file)
     self.assertEqual(self.app.static_folder, "/")
Example #13
0
File: config.py Project: Tefnet/eve
 def test_custom_kwargs(self):
     self.app = Eve('custom_import_name',
                    static_folder='/',
                    settings='eve/tests/test_settings.py')
     self.assertEqual(self.app.static_folder, '/')
 def test_custom_kwargs(self):
     self.app = Eve('unittest', static_folder='/',
                    settings=self.settings_file)
     self.assertEqual(self.app.static_folder, '/')
Example #15
0
 def test_settings_as_dict(self):
     my_settings = {"API_VERSION": "override!", "DOMAIN": {"contacts": {}}}
     self.app = Eve(settings=my_settings)
     self.assertEqual(self.app.config["API_VERSION"], "override!")
     # did not reset other defaults
     self.assertEqual(self.app.config["MONGO_WRITE_CONCERN"], {"w": 1})
 def test_settings_as_dict(self):
     my_settings = {'API_VERSION': 'override!', 'DOMAIN': {'contacts': {}}}
     self.app = Eve(settings=my_settings)
     self.assertEqual(self.app.config['API_VERSION'], 'override!')
     # did not reset other defaults
     self.assertEqual(self.app.config['MONGO_WRITE_CONCERN'], {'w': 1})
Example #17
0
#!/usr/local/bin/python2.7
# -*-coding:UTF-8-sig -*-
from eve.flaskapp import Eve
from eve_sqlalchemy import SQL

from base import Base

app = Eve(auth=None, settings='config/eve-config.py', data=SQL)
db = app.data.driver
Base.metadata.bind = db.engine
db.Model = Base
db.create_all()

if __name__ == '__main__':
    app.run(host="0.0.0.0",port=5000,debug=True)