def test_all_environment_is_not_case_sensitive(self): config = Config('{"Prod": {"Shared": "production!"}, "All": {"Shared": "none", "AllOnly": "works"}}') config = config.for_environment("Prod") self.assertEqual(config.all_only, "works") config = Config('{"Prod": {"Shared": "production!"}, "all": {"Shared": "none", "AllOnly": "works"}}') config = config.for_environment("Prod") self.assertEqual(config.all_only, "works")
def test_all_environment_is_not_case_sensitive(self): config = Config( '{"Prod": {"Shared": "production!"}, "All": {"Shared": "none", "AllOnly": "works"}}' ) config = config.for_environment("Prod") self.assertEqual(config.all_only, "works") config = Config( '{"Prod": {"Shared": "production!"}, "all": {"Shared": "none", "AllOnly": "works"}}' ) config = config.for_environment("Prod") self.assertEqual(config.all_only, "works")
def test_supports_deep_merge(self): config = Config( '{"Prod": {"Database": {"Server": "prod-sql"}}, "All": {"Database": {"MigrationsPath": "path/to/migrations"}}}' ) config = config.for_environment("Prod") self.assertEqual(config.database.server, "prod-sql") self.assertEqual(config.database.migrations_path, "path/to/migrations")
def test_supports_merge_override(self): json = """ { "Dev": { "Connection": { "server": "dev-server", "database": "dev_database", "SdeConnectionFile": "DEV:sde(file)" } }, "All": { "Connection": { "server": "", "database": "", "instance": "", "user": "******", "password": "******", "version": "", "SdeConnectionFile": "" } } }""" config = Config(json) config = config.for_environment("Dev") self.assertEqual(config.Connection.Server, "dev-server") self.assertEqual(config.Connection.database, "dev_database") self.assertEqual(config.Connection.instance, "") self.assertEqual(config.Connection.user, "default-user") self.assertEqual(config.Connection.password, "default-password") self.assertEqual(config.Connection.version, "") self.assertEqual(config.Connection.SdeConnectionFile, "DEV:sde(file)")
def test_environment_specific_config_overrides_all(self): config = Config( '{"Prod": {"Shared": "production!"}, "All": {"Shared": "none"}}') config = config.for_environment("Prod") self.assertEqual(config.shared, "production!")
def test_environment_specific_config_is_included(self): config = Config(self._json_config) environment_config = config.for_environment("theEnvironment") self.assertEqual(environment_config.the_key, "TheValue")
def test_environment_property_is_included(self): config = Config(self._json_config) environment_config = config.for_environment("theEnvironment") self.assertEqual(environment_config.environment, "theEnvironment")
def test_environment_specific_config_overrides_all(self): config = Config('{"Prod": {"Shared": "production!"}, "All": {"Shared": "none"}}') config = config.for_environment("Prod") self.assertEqual(config.shared, "production!")
def test_supports_deep_merge(self): config = Config('{"Prod": {"Database": {"Server": "prod-sql"}}, "All": {"Database": {"MigrationsPath": "path/to/migrations"}}}') config = config.for_environment("Prod") self.assertEqual(config.database.server, "prod-sql") self.assertEqual(config.database.migrations_path, "path/to/migrations")
def test_environment_specific_config_no_environment_property_if_has_environment_config_json(self): config = Config('{"Prod": {"Environment": "production!"}, "All": {"Shared": "none"}}') config = config.for_environment("Prod") self.assertEqual(config.environment, "production!")