diff --git a/CHANGELOG.md b/CHANGELOG.md index 1be4b53..ace4ef8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## Unreleased ### Added - help text for info_traffic +- ORM configuration options exposed ### Fixed - missing migrations ### Changed diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index 0694c14..8caf406 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -1,6 +1,7 @@ Unreleased: added: - help text for info_traffic + - ORM configuration options exposed fixed: - missing migrations changed: diff --git a/src/django_peeringdb/client_adaptor/load.py b/src/django_peeringdb/client_adaptor/load.py index 12e9b67..3a043cc 100644 --- a/src/django_peeringdb/client_adaptor/load.py +++ b/src/django_peeringdb/client_adaptor/load.py @@ -5,6 +5,7 @@ "PORT", "USER", "PASSWORD", + "OPTIONS", ) diff --git a/tests/test_client_adaptor.py b/tests/test_client_adaptor.py index 3431cf2..fa319c5 100644 --- a/tests/test_client_adaptor.py +++ b/tests/test_client_adaptor.py @@ -46,6 +46,84 @@ def test_database_settings(): assert db_config == expected +def test_database_settings_postgresql(): + db_config = database_settings( + { + "engine": "postgresql", + "name": "test_db", + "host": "localhost", + "port": 5432, + "user": "test_user", + "password": "test_password", + "options": {"options": "-c search_path=peeringdb_schema"}, + } + ) + + expected = { + "ENGINE": "django.db.backends.postgresql", + "NAME": "test_db", + "HOST": "localhost", + "PORT": 5432, + "USER": "test_user", + "PASSWORD": "test_password", + "OPTIONS": {"options": "-c search_path=peeringdb_schema"}, + } + + assert db_config == expected + assert "OPTIONS" in db_config + + +def test_database_settings_mysql(): + db_config = database_settings( + { + "engine": "mysql", + "name": "test_db", + "host": "localhost", + "port": 3306, + "user": "test_user", + "password": "test_password", + } + ) + + expected = { + "ENGINE": "django.db.backends.mysql", + "NAME": "test_db", + "HOST": "localhost", + "PORT": 3306, + "USER": "test_user", + "PASSWORD": "test_password", + } + + assert db_config == expected + + +def test_database_settings_mysql_options(): + db_config = database_settings( + { + "engine": "mysql", + "name": "test_db", + "host": "localhost", + "port": 3306, + "user": "test_user", + "password": "test_password", + "options": {}, + } + ) + + expected = { + "ENGINE": "django.db.backends.mysql", + "NAME": "test_db", + "HOST": "localhost", + "PORT": 3306, + "USER": "test_user", + "PASSWORD": "test_password", + "OPTIONS": {}, + } + + assert db_config == expected + assert "OPTIONS" in db_config + + def test_backend_setup(): Backend.setup() for model in models.all_models: