Skip to content

Commit

Permalink
Merge pull request #108 from robamu-org/cfdp-fix
Browse files Browse the repository at this point in the history
fix tests, CHANGELOG
  • Loading branch information
robamu authored Sep 11, 2023
2 parents 0600069 + a387200 commit b8c7ec8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Changed package license from Apache-2.0 to dual Apache-2.0 or MIT.
- Small change to allow handling more than 4096 bytes in one polling cycle.
- Renamed `args_to_params_tmtc` to `args_to_all_params_tmtc` and `args_to_params_cfdp` to
`args_to_all_params_cfdp`
- `PutRequest` model now stores both destination and source file path as a Python `Path`.

## Added

Expand Down
6 changes: 3 additions & 3 deletions tests/cfdp/test_src_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def common_setup(self, closure_requested: bool):
)

def _common_empty_file_test(self):
dest_path = "/tmp/hello_copy.txt"
dest_path = Path("/tmp/hello_copy.txt")
dest_id = ByteFieldU16(2)
self.seq_num_provider.get_and_increment = MagicMock(return_value=3)
put_req = PutRequest(
Expand Down Expand Up @@ -97,7 +97,7 @@ def _common_empty_file_test(self):
self.assertEqual(self.cfdp_user.eof_sent_indication.call_count, 1)

def _common_small_file_test(self, closure_requested: bool, file_content: str):
dest_path = "/tmp/hello_copy.txt"
dest_path = Path("/tmp/hello_copy.txt")
self.source_id = ByteFieldU32(1)
self.dest_id = ByteFieldU32(2)
self.seq_num_provider.get_and_increment = MagicMock(return_value=2)
Expand Down Expand Up @@ -167,7 +167,7 @@ def _start_source_transaction(
)
self.assertEqual(metadata_pdu.checksum_type, ChecksumType.CRC_32)
self.assertEqual(metadata_pdu.source_file_name, self.file_path.as_posix())
self.assertEqual(metadata_pdu.dest_file_name, put_request.dest_file)
self.assertEqual(metadata_pdu.dest_file_name, put_request.dest_file.as_posix())
self.assertEqual(metadata_pdu.dest_entity_id, dest_id)
self.source_handler.confirm_packet_sent_advance_fsm()

Expand Down
3 changes: 2 additions & 1 deletion tests/cfdp/test_src_handler_nak_closure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from unittest.mock import MagicMock

from spacepackets.cfdp import ConditionCode, Direction
Expand Down Expand Up @@ -75,7 +76,7 @@ def _prepare_dummy_put_req(self, dest_id: UnsignedByteField) -> PutRequest:
return PutRequest(
destination_id=dest_id,
source_file=self.file_path,
dest_file="dummy.txt",
dest_file=Path("dummy.txt"),
# Let the transmission mode be auto-determined by the remote MIB
trans_mode=None,
closure_requested=None,
Expand Down
7 changes: 4 additions & 3 deletions tests/cfdp/test_src_handler_nak_no_closure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import random
import sys
from pathlib import Path

from crcmod.predefined import PredefinedCrc

Expand Down Expand Up @@ -44,7 +45,7 @@ def test_perfectly_segmented_file_pdu_generation(self):
self.source_id = ByteFieldU8(1)
self.dest_id = ByteFieldU8(2)
self.source_handler.source_id = self.source_id
dest_path = "/tmp/hello_two_segments_copy.txt"
dest_path = Path("/tmp/hello_two_segments_copy.txt")
file_size, crc32 = self._transaction_with_file_data_wrapper(
dest_path, rand_data
)
Expand Down Expand Up @@ -73,7 +74,7 @@ def test_segmented_file_pdu_generation(self):
self.source_id = ByteFieldU16(1)
self.dest_id = ByteFieldU16(2)
self.source_handler.source_id = self.source_id
dest_path = "/tmp/hello_two_segments_imperfect_copy.txt"
dest_path = Path("/tmp/hello_two_segments_imperfect_copy.txt")
file_size, crc32 = self._transaction_with_file_data_wrapper(
dest_path, rand_data
)
Expand Down Expand Up @@ -151,7 +152,7 @@ def _second_file_segment_handling(self, source_handler: SourceHandler):
return fsm_res.pdu_holder.to_file_data_pdu()

def _transaction_with_file_data_wrapper(
self, dest_path: str, data: bytes
self, dest_path: Path, data: bytes
) -> (int, bytes):
put_req = PutRequest(
destination_id=self.dest_id,
Expand Down
2 changes: 1 addition & 1 deletion tmtccmd/cfdp/handler/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def _prepare_metadata_pdu(self):
self._params.pdu_conf.crc_flag = self._params.remote_cfg.crc_on_transmission
self._params.pdu_conf.direction = Direction.TOWARDS_RECEIVER
params = MetadataParams(
dest_file_name=self._put_req.dest_file,
dest_file_name=self._put_req.dest_file.as_posix(),
source_file_name=self._put_req.source_file.as_posix(),
checksum_type=self._params.crc_helper.checksum_type,
closure_requested=self._params.closure_requested,
Expand Down
6 changes: 3 additions & 3 deletions tmtccmd/cfdp/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def __init__(self, req_type: CfdpRequestType):
@dataclasses.dataclass
class PutRequest:
"""This is the base class modelling put request. You can create this class from the simplified
:py:class:`tmtccmd.config.defs.CfdpParams` class with the
:py:func:`tmtccmd.config.cfdp.cfdp_req_to_put_req_regular` and
:py:func:`tmtccmd.config.cfdp.cfdp_req_to_put_req_proxy_get_req` API."""
:py:class:`tmtccmd.config.defs.CfdpParams` class with the generic
:py:func:`tmtccmd.config.cfdp.generic_cfdp_params_to_put_request` API and/or all related specific
APIs."""

destination_id: UnsignedByteField
# All the following fields are optional because a put request can also be a metadata-only
Expand Down
2 changes: 1 addition & 1 deletion tmtccmd/config/cfdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def cfdp_req_to_put_req_proxy_put_req(
) -> Optional[PutRequest]:
"""Generic function to convert the internalized CFDP parameters to a proxy put request.
:param params CFDP parameters
:param params: CFDP parameters
:param dest_id_put_request: Recipient of the put request.
:param dest_id_proxy_put_req: Recipient of the proxy put operation. For a get request, this
should the the ID of the sender.
Expand Down

0 comments on commit b8c7ec8

Please sign in to comment.