Example #1
0
class AWSAccessConfiguration(Configuration):

    aws_owner_id = environ_setting("AWS_OWNER_ID", required=False, default="")
    aws_access_key_id = environ_setting("AWS_ACCESS_KEY_ID", required=True)
    aws_secret_access_key = environ_setting("AWS_SECRET_ACCESS_KEY",
                                            required=True)
    aws_region = environ_setting("AWS_REGION", required=True)
Example #2
0
 def test_improperly_configured(self):
     """
     Test that ImproperlyConfigured is raised on missing setting
     """
     FAKEKEY = 'MISSING_SETTING'
     with self.assertRaises(ImproperlyConfigured):
         environ_setting(FAKEKEY)
Example #3
0
class RedisConfiguration(Configuration):
    """
    Configuration for the Redis database
    """
    host = environ_setting('REDIS_HOST', 'localhost', required=False)
    port = int(environ_setting('REDIS_PORT', 6379, required=False))
    prefix = environ_setting('REDIS_PREFIX', 'feet', required=False)
Example #4
0
 def test_improperly_configured(self):
     """
     Test that ImproperlyConfigured is raised on missing setting
     """
     FAKEKEY = 'MISSING_SETTING'
     with self.assertRaises(ImproperlyConfigured):
         environ_setting(FAKEKEY)
Example #5
0
 def test_environ_setting(self):
     """
     Test settings can be grabbed from environment
     """
     self.assertEqual(self.ENVVAL, environ_setting(self.ENVKEY))
     self.assertEqual(self.ENVVAL, environ_setting(self.ENVKEY, default='15'))
     self.assertEqual(self.ENVVAL, environ_setting(self.ENVKEY, required=False))
     self.assertEqual(self.ENVVAL, environ_setting(self.ENVKEY, default='15', required=False))
Example #6
0
class DBConfig(Config):
    db_host = environ_setting("DB_HOST", required=True)
    db_port = environ_setting("DB_PORT", 5432, required=False)
    db_name = environ_setting("DB_NAME", required=True)
    db_user = environ_setting("DB_USER", required=True)
    db_pass = environ_setting("DB_PASS", required=True)
    # sqlalchemy_database_uri
    SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
        db_user, db_pass, db_host, db_port, db_name)
Example #7
0
 def test_environ_setting(self):
     """
     Test settings can be grabbed from environment
     """
     self.assertEqual(self.ENVVAL, environ_setting(self.ENVKEY))
     self.assertEqual(self.ENVVAL, environ_setting(self.ENVKEY,
                                                   default='15'))
     self.assertEqual(self.ENVVAL,
                      environ_setting(self.ENVKEY, required=False))
     self.assertEqual(
         self.ENVVAL,
         environ_setting(self.ENVKEY, default='15', required=False))
Example #8
0
 def test_configuration_missing(self):
     """
     Test that ConfigurationMissing is warned on missing setting
     """
     FAKEKEY = 'MISSING_SETTING'
     with warnings.catch_warnings(record=True) as w:
         # Cause all warnings to always be triggered.
         warnings.simplefilter("always")
         # Trigger a warning.
         environ_setting(FAKEKEY, required=False)
         # Verify some things
         assert len(w) == 1
         assert issubclass(w[-1].category, ConfigurationMissing)
Example #9
0
 def test_configuration_missing(self):
     """
     Test that ConfigurationMissing is warned on missing setting
     """
     FAKEKEY = 'MISSING_SETTING'
     with warnings.catch_warnings(record=True) as w:
         # Cause all warnings to always be triggered.
         warnings.simplefilter("always")
         # Trigger a warning.
         environ_setting(FAKEKEY, required=False)
         # Verify some things
         assert len(w) == 1
         assert issubclass(w[-1].category, ConfigurationMissing)
Example #10
0
class MecabConfiguration(Configuration):
    """
    Configuration for the web server to run an admin UI.
    """
    mecabdict = environ_setting('MECAB_DICT',
                                '/var/lib/mecab/dic/ipadic-utf8',
                                required=False)
Example #11
0
 def test_enivron_default_other(self):
     """
     Test that a default is returned on not required
     """
     FAKEKEY = 'MISSING_SETTING'
     self.assertEqual(
         '15', environ_setting(FAKEKEY, required=False, default='15'))
Example #12
0
class FeetConfiguration(Configuration):
    """
    Meaningful defaults and required configurations.
    """
    CONF_PATHS = [
        "/etc/feet.yaml",  # System configuration
        os.path.expanduser("~/.feet.yaml"),  # User specific config
        os.path.abspath("conf/feet.yaml"),  # Local configuration
    ]

    debug = True
    database = RedisConfiguration()
    server = ServerConfiguration()
    mecab = MecabConfiguration()
    logfile = environ_setting('LOG_FILE', 'feet.log', required=False)
    loglevel = environ_setting('LOG_LEVEL', 'INFO', required=False)
    timeout = int(environ_setting('TIMEOUT', 180, required=False))
Example #13
0
 def test_environ_default_none(self):
     """
     Test that None is returned on not required
     """
     FAKEKEY = 'MISSING_SETTING'
     self.assertIsNone(environ_setting(FAKEKEY, required=False))
Example #14
0
 def test_environ_default(self):
     """
     Test that a default is returned on required
     """
     FAKEKEY = 'MISSING_SETTING'
     self.assertEqual('15', environ_setting(FAKEKEY, default='15'))
Example #15
0
class ServerConfiguration(Configuration):
    """
    Configuration for the web server to run an admin UI.
    """
    host = environ_setting('SERVER_HOST', 'localhost', required=False)
    port = int(environ_setting('SERVER_PORT', 8888, required=False))
Example #16
0
 def test_environ_default_none(self):
     """
     Test that None is returned on not required
     """
     FAKEKEY = 'MISSING_SETTING'
     self.assertIsNone(environ_setting(FAKEKEY, required=False))
Example #17
0
 def test_enivron_default_other(self):
     """
     Test that a default is returned on not required
     """
     FAKEKEY = 'MISSING_SETTING'
     self.assertEqual('15', environ_setting(FAKEKEY, required=False, default='15'))
Example #18
0
 def test_environ_default(self):
     """
     Test that a default is returned on required
     """
     FAKEKEY = 'MISSING_SETTING'
     self.assertEqual('15', environ_setting(FAKEKEY, default='15'))
Example #19
0
class KahuConfiguration(Configuration):

    url = "https://kahu.bengfort.com"
    api_key = environ_setting("KEKAHU_API_KEY", default="")