Skip to content

Commit

Permalink
Support 202407 (#104)
Browse files Browse the repository at this point in the history
* ORM configuration Options is missing (postgreSQL) #98

* options are useful for other engines as well, not just psql

---------

Co-authored-by: 20C <[email protected]>
  • Loading branch information
vegu and 20c-ed authored Aug 22, 2024
1 parent 5fbb8c6 commit 5ffb835
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Unreleased
### Added
- help text for info_traffic
- ORM configuration options exposed
### Fixed
- missing migrations
### Changed
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Unreleased:
added:
- help text for info_traffic
- ORM configuration options exposed
fixed:
- missing migrations
changed:
Expand Down
1 change: 1 addition & 0 deletions src/django_peeringdb/client_adaptor/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"PORT",
"USER",
"PASSWORD",
"OPTIONS",
)


Expand Down
78 changes: 78 additions & 0 deletions tests/test_client_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5ffb835

Please sign in to comment.