From c546d7f75c262f18ee13aba2b2f786e2c5b59397 Mon Sep 17 00:00:00 2001 From: elay Date: Mon, 24 Jun 2024 16:41:39 -0700 Subject: [PATCH] format --- pcfuncs/ipban/__init__.py | 10 +++++++--- pcfuncs/tests/ipban/test_ipban.py | 23 +++++++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pcfuncs/ipban/__init__.py b/pcfuncs/ipban/__init__.py index 0d126014..72f0e645 100644 --- a/pcfuncs/ipban/__init__.py +++ b/pcfuncs/ipban/__init__.py @@ -17,9 +17,13 @@ def main(mytimer: func.TimerRequest) -> None: datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).isoformat() ) logger.info("Updating the ip ban list at %s", utc_timestamp) - credential: DefaultAzureCredential = DefaultAzureCredential() + credential: DefaultAzureCredential = DefaultAzureCredential() with LogsQueryClient(credential) as logs_query_client: - with TableServiceClient(endpoint=settings.storage_account_url, credential=credential) as table_service_client: - with table_service_client.create_table_if_not_exists(settings.banned_ip_table) as table_client: + with TableServiceClient( + endpoint=settings.storage_account_url, credential=credential + ) as table_service_client: + with table_service_client.create_table_if_not_exists( + settings.banned_ip_table + ) as table_client: task = UpdateBannedIPTask(logs_query_client, table_client) task.run() diff --git a/pcfuncs/tests/ipban/test_ipban.py b/pcfuncs/tests/ipban/test_ipban.py index 848865eb..749c4fd7 100644 --- a/pcfuncs/tests/ipban/test_ipban.py +++ b/pcfuncs/tests/ipban/test_ipban.py @@ -64,12 +64,16 @@ def mock_clients( ) # Use Azurite for unit tests and populate the table with initial data - with TableServiceClient.from_connection_string(CONNECTION_STRING) as table_service_client: - with table_service_client.create_table_if_not_exists(table_name=TEST_BANNED_IP_TABLE) as table_client: - + with TableServiceClient.from_connection_string( + CONNECTION_STRING + ) as table_service_client: + with table_service_client.create_table_if_not_exists( + table_name=TEST_BANNED_IP_TABLE + ) as table_client: + # Pre-populate the banned IP table populate_banned_ip_table(table_client) - + # Yield the clients for use yield logs_query_client, table_client @@ -83,12 +87,16 @@ def integration_clients( ) -> Generator[Tuple[LogsQueryClient, TableClient], Any, None]: credential: DefaultAzureCredential = DefaultAzureCredential() with LogsQueryClient(credential) as logs_query_client: - with TableServiceClient(endpoint=settings.storage_account_url, credential=credential) as table_service_client: - with table_service_client.create_table_if_not_exists(TEST_BANNED_IP_TABLE) as table_client: + with TableServiceClient( + endpoint=settings.storage_account_url, credential=credential + ) as table_service_client: + with table_service_client.create_table_if_not_exists( + TEST_BANNED_IP_TABLE + ) as table_client: # Pre-populate the banned IP table populate_banned_ip_table(table_client) - + # Yield the clients for use yield logs_query_client, table_client @@ -96,7 +104,6 @@ def integration_clients( table_service_client.delete_table(TEST_BANNED_IP_TABLE) - @pytest.mark.integration def test_update_banned_ip_integration( integration_clients: Tuple[LogsQueryClient, TableClient]