From e89ed8cc2d396fb63c9f824f547cd63d9eddf99f Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Tue, 11 Jun 2024 15:20:30 +0100 Subject: [PATCH] rename class CloudwatchLogsQueryService --> CloudwatchService --- ...oudwatch_logs_query_service.py => cloudwatch_service.py} | 2 +- lambdas/services/data_collection_service.py | 6 +++--- .../services/base/test_cloudwatch_logs_query_service.py | 4 ++-- lambdas/tests/unit/services/test_data_collection_service.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) rename lambdas/services/base/{cloudwatch_logs_query_service.py => cloudwatch_service.py} (98%) diff --git a/lambdas/services/base/cloudwatch_logs_query_service.py b/lambdas/services/base/cloudwatch_service.py similarity index 98% rename from lambdas/services/base/cloudwatch_logs_query_service.py rename to lambdas/services/base/cloudwatch_service.py index a3a629dc3..5b30c6fa3 100644 --- a/lambdas/services/base/cloudwatch_logs_query_service.py +++ b/lambdas/services/base/cloudwatch_service.py @@ -9,7 +9,7 @@ logger = LoggingService(__name__) -class CloudwatchLogsQueryService: +class CloudwatchService: def __init__(self): self.logs_client = boto3.client("logs") self.workspace = os.environ["WORKSPACE"] diff --git a/lambdas/services/data_collection_service.py b/lambdas/services/data_collection_service.py index b03df7970..d1320cc2a 100644 --- a/lambdas/services/data_collection_service.py +++ b/lambdas/services/data_collection_service.py @@ -12,7 +12,7 @@ RecordStoreData, StatisticData, ) -from services.base.cloudwatch_logs_query_service import CloudwatchLogsQueryService +from services.base.cloudwatch_service import CloudwatchService from services.base.dynamo_service import DynamoDBService from services.base.s3_service import S3Service from utils.audit_logging_setup import LoggingService @@ -41,7 +41,7 @@ def __init__(self): self.workspace = os.environ["WORKSPACE"] self.output_table_name = os.environ["STATISTICS_TABLE"] - self.logs_query_service = CloudwatchLogsQueryService() + self.cloudwatch_service = CloudwatchService() self.dynamodb_service = DynamoDBService() self.s3_service = S3Service() @@ -218,7 +218,7 @@ def get_active_user_list(self) -> dict[str, list]: def get_cloud_watch_query_result( self, query_params: CloudwatchLogsQueryParams ) -> list[dict]: - return self.logs_query_service.query_logs( + return self.cloudwatch_service.query_logs( query_params=query_params, start_time=self.collection_start_time, end_time=self.collection_end_time, diff --git a/lambdas/tests/unit/services/base/test_cloudwatch_logs_query_service.py b/lambdas/tests/unit/services/base/test_cloudwatch_logs_query_service.py index 59f334540..ceed28490 100644 --- a/lambdas/tests/unit/services/base/test_cloudwatch_logs_query_service.py +++ b/lambdas/tests/unit/services/base/test_cloudwatch_logs_query_service.py @@ -1,5 +1,5 @@ import pytest -from services.base.cloudwatch_logs_query_service import CloudwatchLogsQueryService +from services.base.cloudwatch_service import CloudwatchService from tests.unit.conftest import WORKSPACE from tests.unit.helpers.data.statistic.mock_logs_query_results import ( EXPECTED_QUERY_RESULT, @@ -24,7 +24,7 @@ @pytest.fixture def mock_service(set_env, mock_logs_client, patch_sleep): - service = CloudwatchLogsQueryService() + service = CloudwatchService() yield service diff --git a/lambdas/tests/unit/services/test_data_collection_service.py b/lambdas/tests/unit/services/test_data_collection_service.py index b3c100cda..044d00b1a 100644 --- a/lambdas/tests/unit/services/test_data_collection_service.py +++ b/lambdas/tests/unit/services/test_data_collection_service.py @@ -6,7 +6,7 @@ import pytest from freezegun import freeze_time from pytest_unordered import unordered -from services.base.cloudwatch_logs_query_service import CloudwatchLogsQueryService +from services.base.cloudwatch_service import CloudwatchService from services.base.dynamo_service import DynamoDBService from services.base.s3_service import S3Service from services.data_collection_service import DataCollectionService @@ -101,8 +101,8 @@ def mock_implementation(query_params: CloudwatchLogsQueryParams, **_kwargs): return MOCK_UNIQUE_ACTIVE_USER_IDS patched_instance = mocker.patch( - "services.data_collection_service.CloudwatchLogsQueryService", - spec=CloudwatchLogsQueryService, + "services.data_collection_service.CloudwatchService", + spec=CloudwatchService, ).return_value mocked_method = patched_instance.query_logs mocked_method.side_effect = mock_implementation