Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil committed Nov 29, 2023
1 parent c386894 commit dd19d14
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions databasez/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ def __init__(self, url: typing.Union[str, "DatabaseURL"]):
f"Invalid type for DatabaseURL. Expected str or DatabaseURL, got {type(url)}"
)

def _sanitize_password(self, url: URL) -> URL:
@classmethod
def _sanitize_password(cls, url: URL) -> URL:
"""
Making sure all the passwords are allowed.
"""
Expand All @@ -585,7 +586,7 @@ def _sanitize_password(self, url: URL) -> URL:
def components(self) -> SplitResult:
if not hasattr(self, "_components"):
raw_url = make_url(self._url)
url = self._sanitize_password(raw_url)
url = DatabaseURL._sanitize_password(raw_url)
self._components = urlsplit(url.render_as_string(hide_password=False))
return self._components

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "password*1123456879#"
POSTGRES_PASSWORD: "passwsss*1348394#"
POSTGRES_DB: "testsuite"
expose:
- "5432"
Expand All @@ -19,8 +19,8 @@ services:
environment:
MYSQL_USER: "mysql"
MYSQL_PASSWORD: "mysql"
MYSQL_DATABASE: "testsuite"
MYSQL_ROOT_PASSWORD: "password*1123456879#"
MYSQL_DATABASE: "passwsss*1348394#"
MYSQL_ROOT_PASSWORD: "password"
expose:
- "3306"
ports:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@

import pytest
import sqlalchemy
from sqlalchemy.engine import URL, make_url

from databasez import Database, DatabaseURL

assert "TEST_DATABASE_URLS" in os.environ, "TEST_DATABASE_URLS is not set."

DATABASE_URLS = [url.strip() for url in os.environ["TEST_DATABASE_URLS"].split(",")]


DATABASE_CONFIG_URLS = []
for value in DATABASE_URLS:
spliter = urlsplit(value)
raw_url = make_url(value)
url: URL = DatabaseURL._sanitize_password(raw_url)
spliter = urlsplit(url.render_as_string(hide_password=False))
DATABASE_CONFIG_URLS.append(
{
"connection": {
Expand All @@ -39,7 +43,7 @@

class AsyncMock(MagicMock):
async def __call__(self, *args, **kwargs):
return super(AsyncMock, self).__call__(*args, **kwargs)
return super().__call__(*args, **kwargs)


class MyEpochType(sqlalchemy.types.TypeDecorator):
Expand Down

0 comments on commit dd19d14

Please sign in to comment.