Skip to content

Commit

Permalink
Refactor: Improve code readability in tests by formatting imports and…
Browse files Browse the repository at this point in the history
… line breaks
  • Loading branch information
LeoQuote committed Feb 28, 2025
1 parent 0d46526 commit 7f17f74
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions sql/engines/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
from sql.engines.mongo import MongoEngine
from sql.engines.clickhouse import ClickHouseEngine
from sql.engines.odps import ODPSEngine
from sql.models import DataMaskingColumns, Instance, SqlWorkflow, SqlWorkflowContent, Tunnel
from sql.models import (
DataMaskingColumns,
Instance,
SqlWorkflow,
SqlWorkflowContent,
Tunnel,
)


User = get_user_model()
Expand Down Expand Up @@ -2506,19 +2512,19 @@ def test_get_all_columns_by_tb(self, mock_get_connection):


def test_ssh(db_instance, mocker: MockerFixture):
tunnel = Tunnel.objects.create(
tunnel_name="test",
host="test",
port=22
)
tunnel = Tunnel.objects.create(tunnel_name="test", host="test", port=22)
db_instance.tunnel = tunnel
db_instance.save()

class FakeTunnel:
def get_ssh(self):
return "remote_host", "remote_password"
mocker.patch('sql.engines.SSHConnection', return_value=FakeTunnel())

mocker.patch("sql.engines.SSHConnection", return_value=FakeTunnel())
from sql.engines import EngineBase

engine = EngineBase(instance=db_instance)
remote_host, remote_password, _, _ = engine.remote_instance_conn(instance=engine.instance)
remote_host, remote_password, _, _ = engine.remote_instance_conn(
instance=engine.instance
)
assert (remote_host, remote_password) == ("remote_host", "remote_password")

0 comments on commit 7f17f74

Please sign in to comment.