Ejemplo n.º 1
0
 def test_raise_exception_if_pattern_not_found(self):
     settings = SettingsManager(
         {
             r"DYNAMIC_\w+_ATTRIBUTE": {
                 "default": "default_value",
                 "description": "dynammic descritpion",
             }
         }
     )
     with self.assertRaises(AttributeNotFoundInSettings):
         settings.read_value("DYNAMIC__ATTRIBUTE")
Ejemplo n.º 2
0
 def test_get_default_value_with_declared_type_for_dynamic_attribute(self):
     settings = SettingsManager(
         {
             "BOOL_SETTING": {
                 "default": "false",
                 "type": "bool",
                 "description": "dynammic descritpion",
             }
         }
     )
     self.assertEqual(False, settings.read_value("BOOL_SETTING"))
Ejemplo n.º 3
0
    def test_get_default_value_for_dynamic_attribute(self):
        settings = SettingsManager(
            {
                r"DYNAMIC_\w+_ATTRIBUTE": {
                    "default": "default_value",
                    "description": "dynammic descritpion",
                }
            }
        )

        self.assertEqual(settings.read_value("DYNAMIC_TEST_ATTRIBUTE"), "default_value")
Ejemplo n.º 4
0
 def test_setting_with_declared_type_returns_converted_value(self):
     settings = SettingsManager(
         {
             "LIFEGUARD_SERVER_PORT": {
                 "default": "5567",
                 "type": "int",
                 "description": "Lifeguard server port number",
             }
         }
     )
     current_value = settings.read_value("LIFEGUARD_SERVER_PORT")
     self.assertEqual(current_value, 5567)
Ejemplo n.º 5
0
 def test_get_allowed_validations_returns_2_validations(self):
     settings = SettingsManager(
         {
             "LIFEGUARD_RUN_ONLY_VALIDATIONS": {
                 "default": "validation1,validation2",
                 "type": "validation_list",
                 "description": "allowed validations",
             }
         }
     )
     self.assertEqual(
         ["validation1", "validation2"],
         settings.read_value("LIFEGUARD_RUN_ONLY_VALIDATIONS"),
     )
Ejemplo n.º 6
0
 def test_get_value_for_dynamic_attribute_from_env(self, mock_environ):
     mock_environ.get.return_value = "from env"
     settings = SettingsManager(
         {
             r"DYNAMIC_\w+_ATTRIBUTE": {
                 "default": "default_value",
                 "description": "dynammic descritpion",
             }
         }
     )
     self.assertEqual(settings.read_value("DYNAMIC_TEST_ATTRIBUTE"), "from env")
     mock_environ.get.assert_has_calls(
         [
             call("DYNAMIC_\\w+_ATTRIBUTE", "default_value"),
             call("DYNAMIC_TEST_ATTRIBUTE", "default_value"),
         ]
     )
Ejemplo n.º 7
0
    def test_get_value_with_type_for_dynamic_attribute_from_env(self, mock_environ):
        mock_environ.get.return_value = "false"
        settings = SettingsManager(
            {
                "DYNAMIC_TEST_ATTRIBUTE": {
                    "default": "default_value",
                    "type": "bool",
                    "description": "dynammic descritpion",
                }
            }
        )

        self.assertEqual(False, settings.read_value("DYNAMIC_TEST_ATTRIBUTE"))
        mock_environ.get.assert_has_calls(
            [
                call("DYNAMIC_TEST_ATTRIBUTE", "default_value"),
            ]
        )
Ejemplo n.º 8
0
"""
Lifeguard MongoDB Settings
"""
from lifeguard.settings import SettingsManager

SETTINGS_MANAGER = SettingsManager({
    "LIFEGUARD_GOOGLE_DEFAULT_CHAT_ROOM": {
        "default": "",
        "description": "Incoming webhook full address",
    },
    "LIFEGUARD_GOOGLE_LOG_RESPONSE": {
        "default": "false",
        "type": "bool",
        "description": "Incoming webhook full address",
    },
})

GOOGLE_DEFAULT_CHAT_ROOM = SETTINGS_MANAGER.read_value(
    "LIFEGUARD_GOOGLE_DEFAULT_CHAT_ROOM")
GOOGLE_LOG_RESPONSE = SETTINGS_MANAGER.read_value(
    "LIFEGUARD_GOOGLE_LOG_RESPONSE")
Ejemplo n.º 9
0
"""
Lifeguard TinyDB Settings
"""
from lifeguard.settings import SettingsManager

SETTINGS_MANAGER = SettingsManager({
    "LIFEGUARD_TINYDB_LOCATION": {
        "default": "lifeguard.json",
        "description": "Path to database file",
    },
})

LIFEGUARD_TINYDB_LOCATION = SETTINGS_MANAGER.read_value(
    "LIFEGUARD_TINYDB_LOCATION")
Ejemplo n.º 10
0
"""
Lifeguard MongoDB Settings
"""
from lifeguard.settings import SettingsManager

SETTINGS_MANAGER = SettingsManager({
    "LIFEGUARD_MONGODB_DATABASE": {
        "default": "lifeguard",
        "description": "MongoDB database name",
    },
    "LIFEGUARD_MONGODB_URL": {
        "default": "mongodb://localhost:27017",
        "description": "MongoDB connection url",
    },
})

LIFEGUARD_MONGODB_URL = SETTINGS_MANAGER.read_value("LIFEGUARD_MONGODB_URL")
LIFEGUARD_MONGODB_DATABASE = SETTINGS_MANAGER.read_value(
    "LIFEGUARD_MONGODB_DATABASE")