From dadbcb17823f778fd5b2820e20040f9ca344f2f2 Mon Sep 17 00:00:00 2001 From: Sascha Doemer Date: Thu, 2 May 2024 17:41:46 +0200 Subject: [PATCH] Refactor messaging services and minor changes in file structures Made several changes in messaging services including restructuring and moving certain classes to align with design patterns. Also made minor changes and updates in file structures of various test scripts and source files. Improved unified decoding strategy with EncodingService class. --- example_script.py | 8 +- src/agrirouter/service/certification.py | 2 +- src/agrirouter/service/client/http.py | 2 +- src/agrirouter/service/dto/messaging.py | 217 ------------------ src/agrirouter/service/messaging/cloud.py | 2 +- src/agrirouter/service/messaging/encoding.py | 2 +- .../service/messaging/message_sending.py | 3 +- src/agrirouter/service/onboarding.py | 5 +- src/agrirouter/service/parameter/messaging.py | 4 +- tests/agrirouter/common/onboarding.py | 2 +- .../onboard_response_integration_service.py | 2 +- .../fixtures/update_http_onboard_responses.py | 6 +- .../fixtures/update_mqtt_onboard_responses.py | 4 +- .../test_environmental_services.py | 4 +- .../internal/messaging/test_decode.py | 2 +- .../onboarding/test_onboarding_dto.py | 2 +- .../messaging/mqtt/test_capability_service.py | 4 +- .../mqtt/test_feed_confirm_service.py | 7 +- .../mqtt/test_feed_delete_service.py | 6 +- .../mqtt/test_list_endpoints_service.py | 4 +- .../mqtt/test_publish_message_service.py | 6 +- .../mqtt/test_query_header_service.py | 7 +- .../mqtt/test_query_message_service.py | 7 +- ..._receive_chunked_messages_from_the_feed.py | 8 +- ...ges_and_receive_with_push_notifications.py | 7 +- .../mqtt/test_send_direct_message_service.py | 6 +- .../mqtt/test_subscription_service.py | 4 +- 27 files changed, 54 insertions(+), 279 deletions(-) delete mode 100644 src/agrirouter/service/dto/messaging.py diff --git a/example_script.py b/example_script.py index 01c6ab8..1bc25bc 100644 --- a/example_script.py +++ b/example_script.py @@ -1,21 +1,21 @@ import time import agrirouter as ar from agrirouter.api.enums import CapabilityType +from agrirouter.service.dto.response.messaging import OnboardResponse +from agrirouter.service.messaging.common import MqttMessagingService, HttpMessagingService +from agrirouter.service.messaging.message_sending import ListEndpointsService, CapabilitiesService, SubscriptionService, \ + QueryHeaderService from agrirouter.service.parameter.messaging import QueryHeaderParameters, ListEndpointsParameters, \ CapabilitiesParameters, SubscriptionParameters -from agrirouter.service.messaging import QueryHeaderService, ListEndpointsService, CapabilitiesService, \ - SubscriptionService from agrirouter.api.enums import Gateways from agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification -from agrirouter.service.messaging import HttpMessagingService, MqttMessagingService from agrirouter.util.uuid_util import UUIDUtil from google.protobuf.timestamp_pb2 import Timestamp from agrirouter.generated.messaging.request.payload.account.endpoints_pb2 import ListEndpointsQuery from agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod -from agrirouter.service.onboarding import OnboardResponse public_key = """-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzGt41/+kSOTlO1sJvLIN diff --git a/src/agrirouter/service/certification.py b/src/agrirouter/service/certification.py index 35e7092..2a6550b 100644 --- a/src/agrirouter/service/certification.py +++ b/src/agrirouter/service/certification.py @@ -1,7 +1,7 @@ import os import tempfile -from agrirouter.service.dto.response.onboarding import OnboardResponse +from agrirouter.service.dto.response.messaging import OnboardResponse class CertificationService: diff --git a/src/agrirouter/service/client/http.py b/src/agrirouter/service/client/http.py index 7842552..fb866bc 100644 --- a/src/agrirouter/service/client/http.py +++ b/src/agrirouter/service/client/http.py @@ -5,7 +5,7 @@ from urllib.parse import urlparse from agrirouter.service.certification import CertificationService -from agrirouter.service.dto.response.onboarding import OnboardResponse +from agrirouter.service.dto.response.messaging import OnboardResponse class HttpClient: diff --git a/src/agrirouter/service/dto/messaging.py b/src/agrirouter/service/dto/messaging.py deleted file mode 100644 index 8256d15..0000000 --- a/src/agrirouter/service/dto/messaging.py +++ /dev/null @@ -1,217 +0,0 @@ -from copy import deepcopy -from typing import List - -from agrirouter.api.messages import EncodedMessage -from agrirouter.generated.commons.chunk_pb2 import ChunkComponent -from agrirouter.service.dto.response.onboarding import BaseOnboardingResponse - - -class Parameters: - def __init__(self, - *, - application_message_seq_no: int, - application_message_id: str = None, - team_set_context_id: str - ): - self.application_message_seq_no = application_message_seq_no - self.application_message_id = application_message_id - self.team_set_context_id = team_set_context_id - - def get_application_message_seq_no(self): - return self.application_message_seq_no - - def get_application_message_id(self): - return self.application_message_id - - def get_team_set_context_id(self): - return self.team_set_context_id - - def set_application_message_seq_no(self, application_message_seq_no): - self.application_message_seq_no = application_message_seq_no - - def set_application_message_id(self, application_message_id): - self.application_message_id = application_message_id - - def set_team_set_context_id(self, team_set_context_id): - self.team_set_context_id = team_set_context_id - - def validate(self): - pass - - -class MessageParameters(Parameters): - def __init__(self, - *, - application_message_seq_no: int, - application_message_id: str, - team_set_context_id: str = None, - onboarding_response: BaseOnboardingResponse - ): - super(MessageParameters, self).__init__( - application_message_seq_no=application_message_seq_no, - application_message_id=application_message_id, - team_set_context_id=team_set_context_id, - ) - - self.onboarding_response = onboarding_response - - def get_onboarding_response(self) -> BaseOnboardingResponse: - return self.onboarding_response - - -class MessagingParameters(MessageParameters): - - def __init__(self, - *, - application_message_seq_no: int = None, - application_message_id: str = None, - team_set_context_id: str = None, - onboarding_response: BaseOnboardingResponse, - encoded_messages=None - ): - super(MessagingParameters, self).__init__( - application_message_seq_no=application_message_seq_no, - application_message_id=application_message_id, - team_set_context_id=team_set_context_id, - onboarding_response=onboarding_response, - ) - - self._encoded_messages = encoded_messages if encoded_messages else [] - - def get_encoded_messages(self): - return deepcopy(self._encoded_messages) - - def set_encoded_messages(self, encoded_messages: List[EncodedMessage]): - self._encoded_messages = encoded_messages - - def append_encoded_messages(self, encoded_message: EncodedMessage): - self._encoded_messages.append(encoded_message) - - def extend_encoded_messages(self, encoded_messages: List[EncodedMessage]): - self._encoded_messages.extend(encoded_messages) - - -class SendMessageParameters(MessageParameters): - """ - Parameters to send messages to the agrirouter - The class inherits from MessageParameters class - """ - - def __init__(self, - *, - onboarding_response: BaseOnboardingResponse, - technical_message_type: str, - recipients: list = None, - chunk_component=None, - base64_message_content: bytes, - type_url: str = None, - chunk_size: int = None, - application_message_id: str, - application_message_seq_no: int, - mode - ): - """ - onboarding_response: Onboarding response of the sender - technical_message_type: TechnicalMessageType class to be sent - recipients: List of recipients - chunk_components: Chunk Information - base64_message_content: Message content that is sent - type_url: Url needed for MessagePayloadParameters - chunk_size: Define the size of the chunks - application_message_id: The application message ID - application_message_seq_no: Sequence number while sending the messages - to the agrirouter with SequenceNumberService - """ - - super(SendMessageParameters, self).__init__(application_message_id=application_message_id, - application_message_seq_no=application_message_seq_no, - onboarding_response=onboarding_response) - - self._technical_message_type = technical_message_type - self._base64_message_content = base64_message_content - self._type_url = type_url - self._mode = mode - - if recipients: - self._recipients = recipients - - if chunk_component: - self._chunk_component = chunk_component - else: - self._chunk_component = None - - if chunk_size: - self._chunk_size = chunk_size - - def get_technical_message_type(self): - return self._technical_message_type - - def get_recipients(self) -> list: - return self._recipients - - def get_chunk_component(self) -> ChunkComponent: - return self._chunk_component - - def get_base64_message_content(self): - return self._base64_message_content - - def get_type_url(self) -> str: - return self._type_url - - def get_chunk_size(self) -> int: - return self._chunk_size - - def get_mode(self): - return self._mode - - -class ChunkedMessageParameters(MessageParameters): - """ - Parameters to send chunked messages to the agrirouter - The class inherits from MessageParameters class - """ - - def __init__(self, - *, - onboarding_response: BaseOnboardingResponse, - technical_message_type: str = None, - recipients: List = None, - application_message_id: str = None, - application_message_seq_no: int = None, - encoded_chunked_messages: List[str] = None, - ): - """ - onboarding_response: Onboarding response of the sender - technical_message_type: TechnicalMessageType class to be sent - recipients: List of recipients - application_message_id: The application message ID - application_message_seq_no: Sequence number while sending the messages - to the agrirouter with SequenceNumberService - encoded_chunked_messages: List of encoded chunked messages - """ - - super(ChunkedMessageParameters, self).__init__(application_message_id=application_message_id, - application_message_seq_no=application_message_seq_no, - onboarding_response=onboarding_response) - - self._technical_message_type = technical_message_type - self._recipients = recipients - self._encoded_chunked_messages = encoded_chunked_messages - - def get_technical_message_type(self): - return self._technical_message_type - - def set_technical_message_type(self, technical_message_type: str): - self._technical_message_type = technical_message_type - - def get_recipients(self) -> list: - return self._recipients - - def set_recipients(self, recipients: list): - self._recipients = recipients - - def get_encoded_chunked_messages(self) -> List[str]: - return self._encoded_chunked_messages - - def set_encoded_chunked_messages(self, encoded_chunked_messages: List[str]): - self._encoded_chunked_messages = encoded_chunked_messages diff --git a/src/agrirouter/service/messaging/cloud.py b/src/agrirouter/service/messaging/cloud.py index 9edc45a..f5120b7 100644 --- a/src/agrirouter/service/messaging/cloud.py +++ b/src/agrirouter/service/messaging/cloud.py @@ -62,7 +62,7 @@ def encode(parameters: CloudOffboardParameters) -> EncodedMessage: value=offboarding_request.SerializeToString() ) - message_content = encode_message(message_header_parameters, message_payload_parameters) + message_content = EncodingService.encode_message(message_header_parameters, message_payload_parameters) encoded_message = EncodedMessage( id_=UUIDUtil.new_uuid(), content=message_content diff --git a/src/agrirouter/service/messaging/encoding.py b/src/agrirouter/service/messaging/encoding.py index ef05a82..65445a0 100644 --- a/src/agrirouter/service/messaging/encoding.py +++ b/src/agrirouter/service/messaging/encoding.py @@ -8,7 +8,7 @@ from agrirouter.api.messages import MessageParameterTuple from agrirouter.generated.commons.chunk_pb2 import ChunkComponent from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope, RequestPayloadWrapper -from agrirouter.service.dto.response.onboarding import OnboardResponse +from agrirouter.service.dto.response.messaging import OnboardResponse from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.parameter.messaging import MessageHeaderParameters, MessagePayloadParameters from agrirouter.util.utc_time_util import UtcTimeUtil diff --git a/src/agrirouter/service/messaging/message_sending.py b/src/agrirouter/service/messaging/message_sending.py index 6583f75..72369bf 100644 --- a/src/agrirouter/service/messaging/message_sending.py +++ b/src/agrirouter/service/messaging/message_sending.py @@ -9,13 +9,12 @@ from agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import MessageConfirm, MessageDelete, \ MessageQuery from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.dto.messaging import SendMessageParameters, ChunkedMessageParameters from agrirouter.service.messaging.common import AbstractService from agrirouter.service.messaging.encoding import EncodingService from agrirouter.service.parameter.messaging import MessageHeaderParameters, MessagePayloadParameters, \ CapabilitiesParameters, FeedConfirmParameters, FeedDeleteParameters, ListEndpointsParameters, \ SubscriptionParameters, QueryHeaderParameters, QueryMessageParameters, ImageParameters, TaskParameters, \ - EfdiParameters + EfdiParameters, SendMessageParameters, ChunkedMessageParameters from agrirouter.util.type_url import TypeUrl from agrirouter.util.uuid_util import UUIDUtil diff --git a/src/agrirouter/service/onboarding.py b/src/agrirouter/service/onboarding.py index 0edc3e4..cfb9c40 100644 --- a/src/agrirouter/service/onboarding.py +++ b/src/agrirouter/service/onboarding.py @@ -1,11 +1,10 @@ import requests -from agrirouter.service.onboarding.request_headers import SoftwareOnboardingHeader from agrirouter.api.env import BaseEnvironment from agrirouter.api.env import EnvironmentalService from agrirouter.api.exceptions import UnexpectedErrorDuringOnboarding, RequestNotSigned -from agrirouter.service.dto.request.onboarding import OnboardRequest, SoftwareOnboardingBody -from agrirouter.service.dto.response.onboarding import VerificationResponse, OnboardResponse +from agrirouter.service.dto.request.onboarding import OnboardRequest, SoftwareOnboardingBody, SoftwareOnboardingHeader +from agrirouter.service.dto.response.messaging import VerificationResponse, OnboardResponse from agrirouter.service.parameter.onboarding import OnboardParameters diff --git a/src/agrirouter/service/parameter/messaging.py b/src/agrirouter/service/parameter/messaging.py index c5dafce..bc7c0af 100644 --- a/src/agrirouter/service/parameter/messaging.py +++ b/src/agrirouter/service/parameter/messaging.py @@ -1,13 +1,13 @@ from copy import deepcopy from typing import List +from agrirouter.api.messages import EncodedMessage from agrirouter.generated.commons.chunk_pb2 import ChunkComponent from agrirouter.generated.commons.message_pb2 import Metadata from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification from agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription from agrirouter.generated.messaging.request.payload.feed.feed_requests_pb2 import ValidityPeriod -from agrirouter.service.dto.messaging import MessageParameters -from agrirouter.service.dto.response.onboarding import BaseOnboardingResponse +from agrirouter.service.dto.response.messaging import BaseOnboardingResponse class Parameters: diff --git a/tests/agrirouter/common/onboarding.py b/tests/agrirouter/common/onboarding.py index 31123db..842aaa6 100644 --- a/tests/agrirouter/common/onboarding.py +++ b/tests/agrirouter/common/onboarding.py @@ -1,5 +1,5 @@ +from agrirouter.service.dto.response.messaging import OnboardResponse from agrirouter.service.onboarding import OnboardParameters -from agrirouter.service.onboarding import OnboardResponse from agrirouter.service.onboarding import OnboardingService from tests.agrirouter.data.applications import CommunicationUnit diff --git a/tests/agrirouter/data/onboard_response_integration_service.py b/tests/agrirouter/data/onboard_response_integration_service.py index dc4d53b..754d6c0 100644 --- a/tests/agrirouter/data/onboard_response_integration_service.py +++ b/tests/agrirouter/data/onboard_response_integration_service.py @@ -2,7 +2,7 @@ import os import tests -from agrirouter.service.onboarding import OnboardResponse +from agrirouter.service.dto.response.messaging import OnboardResponse def read_onboard_response(identifier: str) -> OnboardResponse: diff --git a/tests/agrirouter/fixtures/update_http_onboard_responses.py b/tests/agrirouter/fixtures/update_http_onboard_responses.py index 7ab5757..cbcb423 100644 --- a/tests/agrirouter/fixtures/update_http_onboard_responses.py +++ b/tests/agrirouter/fixtures/update_http_onboard_responses.py @@ -7,9 +7,9 @@ from agrirouter.api.enums import CertificateTypes, Gateways from agrirouter.api.env import Qa from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification -from agrirouter.service.messaging import CapabilitiesService -from agrirouter.service.messaging import HttpMessagingService -from agrirouter.service.messaging.http import FetchMessageService +from agrirouter.service.messaging.common import HttpMessagingService +from agrirouter.service.messaging.http.message_fetching import FetchMessageService +from agrirouter.service.messaging.message_sending import CapabilitiesService from agrirouter.service.onboarding import OnboardResponse from agrirouter.service.parameter.messaging import CapabilitiesParameters from agrirouter.util.uuid_util import UUIDUtil diff --git a/tests/agrirouter/fixtures/update_mqtt_onboard_responses.py b/tests/agrirouter/fixtures/update_mqtt_onboard_responses.py index 975a954..e5034cc 100644 --- a/tests/agrirouter/fixtures/update_mqtt_onboard_responses.py +++ b/tests/agrirouter/fixtures/update_mqtt_onboard_responses.py @@ -5,9 +5,9 @@ from agrirouter.api.env import Qa from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification -from agrirouter.service.messaging import CapabilitiesService -from agrirouter.service.messaging import MqttMessagingService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import CapabilitiesService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.parameter.messaging import CapabilitiesParameters from agrirouter.util.uuid_util import UUIDUtil diff --git a/tests/agrirouter/internal/environments/test_environmental_services.py b/tests/agrirouter/internal/environments/test_environmental_services.py index 66dce37..7f4011f 100644 --- a/tests/agrirouter/internal/environments/test_environmental_services.py +++ b/tests/agrirouter/internal/environments/test_environmental_services.py @@ -1,8 +1,6 @@ """Test src/env/environmental_services.py""" -from src.agrirouter.env.environmental_services import EnvironmentalService - -from src.agrirouter.api.env import Qa, Production +from src.agrirouter.api.env import Qa, Production, EnvironmentalService def test_arclient_set_env(): diff --git a/tests/agrirouter/internal/messaging/test_decode.py b/tests/agrirouter/internal/messaging/test_decode.py index f2f1eeb..779fb26 100644 --- a/tests/agrirouter/internal/messaging/test_decode.py +++ b/tests/agrirouter/internal/messaging/test_decode.py @@ -31,7 +31,7 @@ def test_decode_details(): json_response = json.loads(MESSAGING_RESULT) message = DecodingService.decode_response(json_response[0]["command"]["message"].encode()) details = message.response_payload.details - decoded_details = decode_details(details) + decoded_details = DecodingService.decode_details(details) assert decoded_details.endpoints assert len(decoded_details.endpoints) == 2 diff --git a/tests/agrirouter/internal/onboarding/test_onboarding_dto.py b/tests/agrirouter/internal/onboarding/test_onboarding_dto.py index aeef747..294c0ee 100644 --- a/tests/agrirouter/internal/onboarding/test_onboarding_dto.py +++ b/tests/agrirouter/internal/onboarding/test_onboarding_dto.py @@ -2,7 +2,7 @@ import pytest from agrirouter.api.exceptions import WrongField -from agrirouter.service.onboarding import ConnectionCriteria, Authentication, ErrorResponse +from agrirouter.service.dto.response.onboarding import Authentication, ConnectionCriteria, ErrorResponse class TestConnectionCriteria: diff --git a/tests/agrirouter/service/messaging/mqtt/test_capability_service.py b/tests/agrirouter/service/messaging/mqtt/test_capability_service.py index c415e76..e07851a 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_capability_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_capability_service.py @@ -7,9 +7,9 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification -from agrirouter.service.messaging import CapabilitiesService -from agrirouter.service.messaging import MqttMessagingService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import CapabilitiesService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.parameter.messaging import CapabilitiesParameters from agrirouter.util.uuid_util import UUIDUtil diff --git a/tests/agrirouter/service/messaging/mqtt/test_feed_confirm_service.py b/tests/agrirouter/service/messaging/mqtt/test_feed_confirm_service.py index 11e30c2..4aaa8b8 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_feed_confirm_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_feed_confirm_service.py @@ -6,13 +6,12 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.dto.messaging import SendMessageParameters -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SendMessageService, FeedDeleteService, FeedConfirmService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import SendMessageService, FeedDeleteService, FeedConfirmService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse -from agrirouter.service.parameter.messaging import FeedDeleteParameters, FeedConfirmParameters +from agrirouter.service.parameter.messaging import FeedDeleteParameters, FeedConfirmParameters, SendMessageParameters from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider from tests.agrirouter.common.sleeper import Sleeper diff --git a/tests/agrirouter/service/messaging/mqtt/test_feed_delete_service.py b/tests/agrirouter/service/messaging/mqtt/test_feed_delete_service.py index 265709d..9ca3219 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_feed_delete_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_feed_delete_service.py @@ -6,11 +6,11 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SendMessageService, SendMessageParameters, FeedDeleteService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import SendMessageService, FeedDeleteService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService -from agrirouter.service.parameter.messaging import FeedDeleteParameters +from agrirouter.service.parameter.messaging import FeedDeleteParameters, SendMessageParameters from agrirouter.util.utc_time_util import UtcTimeUtil from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider diff --git a/tests/agrirouter/service/messaging/mqtt/test_list_endpoints_service.py b/tests/agrirouter/service/messaging/mqtt/test_list_endpoints_service.py index d2cbac9..51377b5 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_list_endpoints_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_list_endpoints_service.py @@ -5,9 +5,9 @@ from agrirouter.api.enums import CapabilityType, CapabilityDirectionType from agrirouter.api.messages import OutboxMessage -from agrirouter.service.messaging import ListEndpointsService -from agrirouter.service.messaging import MqttMessagingService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import ListEndpointsService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.parameter.messaging import ListEndpointsParameters from agrirouter.util.uuid_util import UUIDUtil diff --git a/tests/agrirouter/service/messaging/mqtt/test_publish_message_service.py b/tests/agrirouter/service/messaging/mqtt/test_publish_message_service.py index 098892a..b130a7c 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_publish_message_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_publish_message_service.py @@ -6,12 +6,12 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SendMessageService, SendMessageParameters, FeedDeleteService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import SendMessageService, FeedDeleteService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse -from agrirouter.service.parameter.messaging import FeedDeleteParameters +from agrirouter.service.parameter.messaging import FeedDeleteParameters, SendMessageParameters from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider from tests.agrirouter.common.sleeper import Sleeper diff --git a/tests/agrirouter/service/messaging/mqtt/test_query_header_service.py b/tests/agrirouter/service/messaging/mqtt/test_query_header_service.py index 5267c91..8ecd7ec 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_query_header_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_query_header_service.py @@ -7,13 +7,12 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SendMessageService, SendMessageParameters, FeedDeleteService, \ - QueryHeaderService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import FeedDeleteService, QueryHeaderService, SendMessageService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse -from agrirouter.service.parameter.messaging import FeedDeleteParameters, QueryHeaderParameters +from agrirouter.service.parameter.messaging import FeedDeleteParameters, QueryHeaderParameters, SendMessageParameters from agrirouter.util.utc_time_util import UtcTimeUtil from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider diff --git a/tests/agrirouter/service/messaging/mqtt/test_query_message_service.py b/tests/agrirouter/service/messaging/mqtt/test_query_message_service.py index 4f97248..62528c4 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_query_message_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_query_message_service.py @@ -7,13 +7,12 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SendMessageService, SendMessageParameters, FeedDeleteService, \ - QueryMessagesService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import SendMessageService, FeedDeleteService, QueryMessagesService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse -from agrirouter.service.parameter.messaging import FeedDeleteParameters, QueryMessageParameters +from agrirouter.service.parameter.messaging import FeedDeleteParameters, QueryMessageParameters, SendMessageParameters from agrirouter.util.utc_time_util import UtcTimeUtil from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider diff --git a/tests/agrirouter/service/messaging/mqtt/test_send_and_receive_chunked_messages_from_the_feed.py b/tests/agrirouter/service/messaging/mqtt/test_send_and_receive_chunked_messages_from_the_feed.py index b715f69..8f0a247 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_send_and_receive_chunked_messages_from_the_feed.py +++ b/tests/agrirouter/service/messaging/mqtt/test_send_and_receive_chunked_messages_from_the_feed.py @@ -7,15 +7,15 @@ from agrirouter.api.enums import CapabilityType, TechnicalMessageType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.dto.messaging import ChunkedMessageParameters -from agrirouter.service.messaging import FeedDeleteService, SendChunkedMessageService, QueryHeaderService -from agrirouter.service.messaging import MqttMessagingService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService from agrirouter.service.messaging.encoding import EncodingService +from agrirouter.service.messaging.message_sending import FeedDeleteService, SendChunkedMessageService, \ + QueryHeaderService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse from agrirouter.service.parameter.messaging import FeedDeleteParameters, MessageHeaderParameters, \ - MessagePayloadParameters, QueryHeaderParameters + MessagePayloadParameters, QueryHeaderParameters, ChunkedMessageParameters from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider from tests.agrirouter.common.sleeper import Sleeper diff --git a/tests/agrirouter/service/messaging/mqtt/test_send_chunked_messages_and_receive_with_push_notifications.py b/tests/agrirouter/service/messaging/mqtt/test_send_chunked_messages_and_receive_with_push_notifications.py index fa27846..438c497 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_send_chunked_messages_and_receive_with_push_notifications.py +++ b/tests/agrirouter/service/messaging/mqtt/test_send_chunked_messages_and_receive_with_push_notifications.py @@ -6,15 +6,14 @@ from agrirouter.api.enums import CapabilityType, TechnicalMessageType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.dto.messaging import ChunkedMessageParameters -from agrirouter.service.messaging import FeedDeleteService, SendChunkedMessageService -from agrirouter.service.messaging import MqttMessagingService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService from agrirouter.service.messaging.encoding import EncodingService +from agrirouter.service.messaging.message_sending import FeedDeleteService, SendChunkedMessageService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse from agrirouter.service.parameter.messaging import FeedDeleteParameters, MessageHeaderParameters, \ - MessagePayloadParameters + MessagePayloadParameters, ChunkedMessageParameters from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider from tests.agrirouter.common.sleeper import Sleeper diff --git a/tests/agrirouter/service/messaging/mqtt/test_send_direct_message_service.py b/tests/agrirouter/service/messaging/mqtt/test_send_direct_message_service.py index 1ecb779..57e14e4 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_send_direct_message_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_send_direct_message_service.py @@ -6,12 +6,12 @@ from agrirouter.api.enums import CapabilityType from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.request_pb2 import RequestEnvelope -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SendMessageService, SendMessageParameters, FeedDeleteService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import SendMessageService, FeedDeleteService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.onboarding import OnboardResponse -from agrirouter.service.parameter.messaging import FeedDeleteParameters +from agrirouter.service.parameter.messaging import FeedDeleteParameters, SendMessageParameters from agrirouter.util.uuid_util import UUIDUtil from tests.agrirouter.common.data_provider import DataProvider from tests.agrirouter.common.sleeper import Sleeper diff --git a/tests/agrirouter/service/messaging/mqtt/test_subscription_service.py b/tests/agrirouter/service/messaging/mqtt/test_subscription_service.py index 26db400..7031dcd 100644 --- a/tests/agrirouter/service/messaging/mqtt/test_subscription_service.py +++ b/tests/agrirouter/service/messaging/mqtt/test_subscription_service.py @@ -7,9 +7,9 @@ from agrirouter.api.messages import OutboxMessage from agrirouter.generated.messaging.request.payload.endpoint.capabilities_pb2 import CapabilitySpecification from agrirouter.generated.messaging.request.payload.endpoint.subscription_pb2 import Subscription -from agrirouter.service.messaging import MqttMessagingService -from agrirouter.service.messaging import SubscriptionService, CapabilitiesService +from agrirouter.service.messaging.common import MqttMessagingService from agrirouter.service.messaging.decoding import DecodingService +from agrirouter.service.messaging.message_sending import CapabilitiesService, SubscriptionService from agrirouter.service.messaging.sequence_numbers import SequenceNumberService from agrirouter.service.parameter.messaging import SubscriptionParameters, CapabilitiesParameters from agrirouter.util.uuid_util import UUIDUtil