Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dwikler committed Jan 3, 2025
1 parent 1ed3aa9 commit 48fc984
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tdwii_plus_examples/cstorescp.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def _add_contexts(self):
# Make ExplicitVRLittleEndian the preferred transfer syntax
transfer_syntaxes.remove(UID(ExplicitVRLittleEndian))
transfer_syntaxes = [UID(ExplicitVRLittleEndian)] + \
transfer_syntaxes
transfer_syntaxes
else:
if ImplicitVRLittleEndian not in self._valid_transfer_syntaxes:
transfer_syntaxes = self._valid_transfer_syntaxes + [
Expand Down
32 changes: 15 additions & 17 deletions tdwii_plus_examples/tests/test_cstorescp_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def _add_private_elements(self, ds):
block.add_new(0x01, 'DS', '123.456') # Decimal String
block.add_new(0x02, 'FL', 789.0123456789) # Float
block.add_new(0x03, 'FD', 789.0123456789) # Double


def tearDown(self):
# Remove the temporary directory and its contents
Expand All @@ -124,20 +123,20 @@ def tearDown(self):
(self.temp_dir, files_in_temp_dir))

@parameterized.expand([
([],),
([uid.ExplicitVRLittleEndian],),
([uid.ImplicitVRLittleEndian],),
([uid.ExplicitVRLittleEndian, uid.ImplicitVRLittleEndian],),
([uid.ExplicitVRBigEndian, uid.ImplicitVRLittleEndian],),
([uid.ImplicitVRLittleEndian, uid.ExplicitVRLittleEndian],),
])
([],),
([uid.ExplicitVRLittleEndian],),
([uid.ImplicitVRLittleEndian],),
([uid.ExplicitVRLittleEndian, uid.ImplicitVRLittleEndian],),
([uid.ExplicitVRBigEndian, uid.ImplicitVRLittleEndian],),
([uid.ImplicitVRLittleEndian, uid.ExplicitVRLittleEndian],),
])
def test_run_and_check_log(self, transfer_syntaxes):
# Create a CStoreSCP instance
self.scp = CStoreSCP(bind_address="localhost",
store_directory=self.temp_dir,
logger=self.scp_logger,
sop_classes=[uid.SecondaryCaptureImageStorage],
transfer_syntaxes=transfer_syntaxes)
store_directory=self.temp_dir,
logger=self.scp_logger,
sop_classes=[uid.SecondaryCaptureImageStorage],
transfer_syntaxes=transfer_syntaxes)
# Run the SCP
self.scp.run()
self.test_logger.info("SCP started successfully")
Expand Down Expand Up @@ -178,19 +177,19 @@ def test_run_and_check_log(self, transfer_syntaxes):
file_path = os.path.join(self.temp_dir, filename)
self.assertTrue(os.path.isfile(file_path),
f"The dataset {file_path} was not stored")

# Print the stored DICOM file content
ds = dcmread(file_path)
self.test_logger.debug(f"DICOM file content:\n{ds}")

# Check that the private elements are present in the stored file
private_block = ds.private_block(0x0011, 'PrivateCreator')
self.assertIn(0x01, private_block,
self.assertIn(0x01, private_block,
"Private element 0x00110001 not found")
self.assertIn(0x02, private_block,
self.assertIn(0x02, private_block,
"Private element 0x00110002 not found")
if ds.file_meta.TransferSyntaxUID in [
uid.ExplicitVRLittleEndian, uid.ExplicitVRBigEndian]:
uid.ExplicitVRLittleEndian, uid.ExplicitVRBigEndian]:
self.assertEqual(
private_block[0x01].value, '123.456',
"Private element 0x00110001 has incorrect value"
Expand Down Expand Up @@ -225,7 +224,6 @@ def test_run_and_check_log(self, transfer_syntaxes):
"Private element 0x00110003 has incorrect value"
)


# Stop the SCP
self.scp.stop()

Expand Down
5 changes: 2 additions & 3 deletions tdwii_plus_examples/tests/test_cstorescp_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def setUpClass(cls):
xfer for xfer, is_valid in XFER_SYNTAXES.items() if is_valid]
cls.invalid_xfer_syntaxes = [
xfer for xfer, is_valid in XFER_SYNTAXES.items() if not is_valid]

# Create the list of default transfer syntaxes
cls.default_transfer_syntaxes = DEFAULT_TRANSFER_SYNTAXES.copy()
# Make ExplicitVRLittleEndian the preferred transfer syntax
cls.default_transfer_syntaxes.remove(UID(uid.ExplicitVRLittleEndian))
cls.default_transfer_syntaxes = [UID(uid.ExplicitVRLittleEndian)] + \
cls.default_transfer_syntaxes
cls.default_transfer_syntaxes
cls.test_logger.debug(f"Default Transfer Syntaxes: "
f"{cls.default_transfer_syntaxes}")

Expand Down Expand Up @@ -195,4 +195,3 @@ def test_init_params(self,
self.assertEqual(scp.handle_store, handler)
elif store_directory:
self.assertEqual(scp.store_directory, store_directory)

0 comments on commit 48fc984

Please sign in to comment.