tests.models package¶
Submodules¶
tests.models.test_fields module¶
Tests for custom fields.
-
class
tests.models.test_fields.
ChoiceArrayFieldTestCase
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for the
ChoiceArrayField
model.-
CHOICES
= (('C1', 'First Choice'), ('C2', 'Second Choice'), ('C3', 'Third Choice'))¶
-
setUp
()¶ Adds a
ChoiceArrayField
instance to the tests’ contexts. For more information see unittest’ssetUp()
method.
-
test_formfield_method
()¶ Tests that
formfield()
method returns the expected value.
-
tests.models.test_image module¶
-
class
tests.models.test_image.
ImageTestCase
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for the
Image
model.-
HEADER_FIELDS
= ['uid', 'number', 'date', 'time']¶
-
NON_HEADER_FIELDS
= ['id', 'dcm', 'created', 'modified', 'series']¶
-
setUp
()¶ Adds the created instances to the tests’ contexts. For more information see unittest’s
setUp()
method.
-
classmethod
setUpTestData
()¶ Creates instances to test the
Image
model. For more information see Django’sTestCase
documentation.
-
test_dcm_extension_validation
()¶ Tests that only .dcm files may be used to instantiate an
Image
instance.
-
test_fields_blank_and_null_configuration
()¶ Every
Image
instance must have all of their fields set. id, created, and modified my be blank in forms.
-
test_get_absolute_url
()¶ Tests the
Image
model’s get_absolute_url method.
-
test_get_b_value
()¶ Tests the
get_b_value()
method. Should return the B-value for DWI images and None for non-DWI images. TODO: Figure out why B-value seems to always be set to 0 for the DWI images.
-
test_get_data
()¶ Tests the
django_dicom.models.image.Image.get_data()
method returns the expected NumPy array.
-
test_get_header_fields
()¶ Tests that the
get_header_fields()
returns the correct fields. The expected fields should be set as this TestCase’s HEADER_FIELDS class attribute.
-
test_get_header_keyword
()¶ Tests that the
get_header_keyword()
method returns the keyword defined in theImage
class’s FIELD_TO_HEADER dictionary, or a CamelCase version of the field name if no such definition exists.
-
test_gradient_diretion
()¶ Tests that the gradient direction can be read for SIEMENS DICOM images. For more information see: https://na-mic.org/wiki/NAMIC_Wiki:DTI:DICOM_for_DWI_and_DTI#Private_vendor:_Siemens.
TODO: Extend to other vendors.
-
test_is_dicom_entity
()¶ Tests that the created
Image
instance inherits fromDicomEntity
.
-
test_is_header_field
()¶ Tests that the
is_header_field()
method returns the correct boolean result for the different fields. Relies on this TestCase’s defintion for the NON_HEADER_FIELDS class attribute.
-
test_number_vebose_name
()¶ Test the number field vebose name.
-
test_read_file_configuration
()¶ By default, the
django_dicom.models.image.Image.read_file()
method is supposed to read the entire image (including the pixel array).
-
test_read_file_method_return_type
()¶ Tests that the
read_file()
method return aFileDataset
instance.
-
test_read_file_with_only_headers
()¶ Tests the
django_dicom.models.image.Image.read_file()
method header_only setting.
-
test_read_header
()¶ Tests that the
read_header()
method returns the expectedHeaderInformation
instance.
-
test_slice_timing
()¶ Tests that the slice timing can be read for SIEMENS DICOM images. For more information see: https://en.wikibooks.org/wiki/SPM/Slice_Timing#Siemens_scanners.
TODO: Extend to other vendors.
-
test_string
()¶ Tests that the instance’s
__str__()
method returns its UID. For more information see Django’s str method documentation.
-
test_uid_is_unique
()¶ Validates that the UID field is unique.
-
test_uid_max_length
()¶ DICOM’s SOPInstanceUID attribute may only be as long as 64 characters ( see the Unique Identifier (UI) value-representation specification).
-
test_uid_vebose_name
()¶ Test the UID field vebose name.
-
test_update_fields_from_header
()¶ Tests that
update_fields_from_header()
method returns the expected values. This test relies on the created instance’s fields containing the expected values beforehand.
-
tests.models.test_patient module¶
-
class
tests.models.test_patient.
PatientTestCase
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for the
Patient
model.-
setUp
()¶ Adds the created instances to the tests’ contexts. For more information see unittest’s
setUp()
method.
-
classmethod
setUpTestData
()¶ Creates instances to be used in the tests. For more information see Django’s
TestCase
documentation.
-
test_date_of_birth_blank_and_null
()¶ The Patient’s Birth Date attribute may be empty (type 2 data element).
-
test_get_absolute_url
()¶ Tests the
get_absolute_url()
method returns the expeted url. More information
-
test_get_full_name
()¶ Tests that the
get_full_name()
method returns “{given_name} {family_name}”.
-
test_name_blank_and_null
()¶ Tests that the name fields are blankable and nullable according to the Patient’s Name DICOM attribute definition (type 2 data element).
-
test_name_max_length
()¶ Tests that the name fields has the expected max_length (see the Person Name (PN) value-representation specification).
-
test_sex_blank_and_null
()¶ The Patient’s Sex attribute may be empty (type 2 data element).
-
test_sex_max_length
()¶ Tests that the sex field has the expected max_length.
-
test_string
()¶ Tests that an
__str__()
method returns its UID. For more information see Django’s str method documentation.
-
test_uid_is_unique
()¶ Validates that the UID field is unique.
-
test_uid_max_length
()¶ DICOM’s Patient ID attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_uid_verbose_name
()¶ Test the UID field vebose name.
-
test_update_fields_from_header
()¶ Tests that
update_fields_from_header()
method returns the expected values. This test relies on the created instance’s fields containing the expected values beforehand.
-
test_update_patient_name
()¶ Tests patient name update according to the DICOM header Patient’s Name (PN) data element fields.
-
tests.models.test_series module¶
-
class
tests.models.test_series.
SeriesTestCase
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for the
Series
model.-
setUp
()¶ Adds the created instances to the tests’ contexts. For more information see unittest’s
setUp()
method.
-
classmethod
setUpTestData
()¶ Creates instances to be used in the tests. For more information see Django’s
TestCase
documentation.
-
test_body_part_examined_blank_and_null
()¶ The Body Part Examined attribute is optional (type 3 data element).
-
test_body_part_examined_max_length
()¶ DICOM’s Body Part Examined attribute may only be as long as 16 characters ( see the Code String (CS) value-representation specification).
-
test_date_blank_and_null
()¶ The Series Date attribute is optional (type 3 data element).
-
test_description_blank_and_null
()¶ The Series Description attribute may be empty (type 2 data element).
-
test_description_max_length
()¶ DICOM’s Series Description attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_description_vebose_name
()¶ Test the description field vebose name.
-
test_device_serial_number_blank_and_null
()¶ The Device Serial Number attribute is optional (type 3 data element).
-
test_device_serial_number_max_length
()¶ DICOM’s Device Serial Number attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_echo_time_positive_float_validation
()¶ The Echo Time attribute measures time in milliseconds and therefore must be positive.
-
test_flip_angle_blank_and_null
()¶ The Flip Angle attribute is optional (type 3 data element).
-
test_get_absolute_url
()¶ Tests the
Series
model’s get_absolute_url method.
-
test_get_data
()¶ Tests retrieving the series data from the model. In this case we only have one instance for each series so the third dimension’s size will be 1.
-
test_get_gradient_directions
()¶ Tests the
get_gradient_directions()
method returns the expected value for the given series.
-
test_get_path
()¶ Tests the
get_path()
method returns the series base directory.
-
test_get_scanning_sequence_display
()¶ Tests the
get_scanning_sequence_display()
method returns the expected value for the given series.
-
test_get_sequence_variant_display
()¶ Tests the
get_sequence_variant_display()
method returns the expected value for the given series.
-
test_institution_name_blank_and_null
()¶ The Institution Name attribute is optional (type 3 data element).
-
test_institution_name_max_length
()¶ DICOM’s Institution Name attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_inversion_time_blank_and_null
()¶ The Inversion Time attribute may be empty (type 2C data element).
-
test_inversion_time_positive_float_validation
()¶ The Inversion Time attribute measures time in milliseconds and therefore must be positive.
-
test_magnetic_field_strengh_blank_and_null
()¶ The Magnetic Field Strength attribute is optional (type 3 data element).
-
test_magnetic_field_strength_positive_float_validation
()¶ The Magnetic Field Strength attribute measures field strength in Tesla (T) and therefore must be positive.
-
test_manufacturer_blank_and_null
()¶ The Manufacturer attribute may be empty (type 2 data element).
-
test_manufacturer_max_length
()¶ DICOM’s Manufacturer attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_manufacturer_model_name_blank_and_null
()¶ The Manufacturer’s Model Name attribute is optional (type 3 data element).
-
test_manufacturer_model_name_max_length
()¶ DICOM’s Manufacturer’s Model Name attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_modality_choices
()¶ Modality is a Code String (CS) data element and therfores has a limited number of possible values.
-
test_mr_acquisition_type_choices
()¶ MR Acquisition Type is a Code String (CS) data element and therfores has a limited number of possible values.
-
test_mr_acquisition_type_max_length
()¶ DICOM’s MR Acquisition Type attribute may only be as long as 2 characters.
-
test_number_blank_and_null
()¶ The Series Number attribute may be empty (type 2 data element).
-
test_number_vebose_name
()¶ Test the number field vebose name.
-
test_patient_blank_and_null
()¶ DICOM’s Patient attributes are all either conditionally required or nullable, and therefore it is possible for the patient relationship to be unused.
-
test_patient_position_blank_and_null
()¶ The Patient Position attribute may be empty (type 2C data element).
-
test_patient_position_choices
()¶ Patient Position is a Code String (CS) data element and therfores has a limited number of possible values.
-
test_patient_position_max_length
()¶ DICOM’s Patient Position attribute may only be as long as 4 characters.
-
test_pixel_spacing_blank_and_null
()¶ The Pixel Spacing attribute may not be empty (type 1 data element).
-
test_pixel_spacing_positive_float_validation
()¶ The Pixel Spacing attribute specifies distances in millimeters, and therefore must be positive.
-
test_pixel_spacing_size
()¶ The Pixel Spacing attribute specifies the distance between the centers of two adjacent pixels in the row (X) and column (Y) dimensions.
-
test_protocol_name_blank_and_null
()¶ The Protocol Name attribute is optional (type 3 data element).
-
test_protocol_name_max_length
()¶ DICOM’s Protocol Name attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_repetition_time_blank_and_null
()¶ The Repetition Time attribute may be empty (type 2C data element).
-
test_repetition_time_positive_float_validation
()¶ The Repetition Time attribute measures time in milliseconds and therefore must be positive.
-
test_scanning_sequence_base_choices
()¶ Scanning Sequence is a Code String (CS) data element and therfores has a limited number of possible values.
-
test_scanning_sequence_base_max_length
()¶ Scanning Sequence definitions are 2 characters long.
-
test_scanning_sequence_blank_and_null
()¶ The Scanning Sequence attribute may not be empty (type 1 data element).
-
test_scanning_sequence_size
()¶ The Scanning Sequence attribute has five possible values, with some of them actually being mutually exclusive. We’re limiting to five in any case.
-
test_sequence_variant_base_choices
()¶ Sequence Variant is a Code String (CS) data element and therfores has a limited number of possible values.
-
test_sequence_variant_base_max_length
()¶ Sequence Variant definitions can be 4 characters long.
-
test_sequence_variant_blank_and_null
()¶ The Sequence Variant attribute may not be empty (type 1 data element).
-
test_sequence_variant_size
()¶ The Sequence Variant attribute has eight possible values, with some of them actually being mutually exclusive and also including NONE. We’re limiting to six just in case.
-
test_series_verbose_name_plural
()¶ Validate the verbose name plural (“Series”) of the
Series
model.
-
test_slice_thickness_blank_and_null
()¶ The Slice Thickness attribute may be empty (type 2 data element).
-
test_slice_thickness_positive_float_validation
()¶ The Slice Thickness attribute measures thickness in millimeters and therefore must be positive.
-
test_string
()¶ Tests that an
Series
instance’s str method returns its UID. For more information see Django’s str method documentation.
-
test_study_blank_and_null
()¶ The Study Instance UID attribute may not be empty (type 1 data element) and therefore every series must have a study.
-
test_time_blank_and_null
()¶ The Series Time attribute is optional (type 3 data element).
-
test_uid_is_unique
()¶ Validates that the UID field is unique.
-
test_uid_max_length
()¶ DICOM’s SeriesInstanceUID attribute may only be as long as 64 characters ( see the Unique Identifier (UI) value-representation specification).
-
test_uid_verbose_name
()¶ Test the UID field vebose name.
-
test_update_fields_from_header
()¶ Tests that
update_fields_from_header()
method returns the expected values. This test relies on the created instance’s fields containing the expected values beforehand.
-
tests.models.test_study module¶
-
class
tests.models.test_study.
SeriesTestCase
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for the
Study
model.-
setUp
()¶ Adds the created instances to the tests’ contexts. For more information see unittest’s
setUp()
method.
-
classmethod
setUpTestData
()¶ Creates instances to be used in the tests. For more information see Django’s
TestCase
documentation.
-
test_date_blank_and_null
()¶ The Study Date attribute may be empty (type 2 data element).
-
test_description_blank_and_null
()¶ The Study Description attribute is optional (type 3 data element).
-
test_description_max_length
()¶ DICOM’s Study Description attribute may only be as long as 64 characters ( see the Long String (LO) value-representation specification).
-
test_get_absolute_url
()¶ Tests the
get_absolute_url()
method returns the expeted url. For more information regarding get_absolute_url see the Django documentation.
-
test_string
()¶ Tests that an
__str__()
method returns its UID. For more information see Django’s str method documentation.
-
test_study_verbose_name_plural
()¶ Validate the verbose name plural (“Studies”) of the
Study
model.
-
test_time_blank_and_null
()¶ The Study Time attribute may be empty (type 2 data element).
-
test_uid_is_unique
()¶ Validates that the UID field is unique.
-
test_uid_max_length
()¶ DICOM’s Study Instance UID attribute may only be as long as 64 characters ( see the Unique Identifier (UI) value-representation specification).
-
test_uid_vebose_name
()¶ Test the UID field vebose name.
-
test_update_fields_from_header
()¶ Tests that
update_fields_from_header()
method returns the expected values. This test relies on the created instance’s fields containing the expected values beforehand.
-