Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models.dag import DAG
from airflow.providers.mysql.hooks.mysql import MySqlHook
Comment thread
potiuk marked this conversation as resolved.
from airflow.providers.postgres.hooks.postgres import PostgresHook
from airflow.utils import timezone

Expand Down Expand Up @@ -65,7 +66,17 @@ def teardown_method(self):
],
)
def test_mysql_to_mysql(self, client):
from providers.tests.mysql.hooks.test_mysql import MySqlContext
class MySqlContext:
def __init__(self, client):
self.client = client
self.connection = MySqlHook.get_connection(MySqlHook.default_conn_name)
self.init_client = self.connection.extra_dejson.get("client", "mysqlclient")

def __enter__(self):
self.connection.set_extra(f'{{"client": "{self.client}"}}')

def __exit__(self, exc_type, exc_val, exc_tb):
self.connection.set_extra(f'{{"client": "{self.init_client}"}}')

with MySqlContext(client):
sql = "SELECT * FROM connection;"
Expand Down