Exemple #1
0
 def test_all_values_are_strings(self):
     for directory, expected_result in self.get_next_test_directory():
         tree = db.browse(directory)
         for fname, tags in tree.items():
             self.assertIsInstance(fname, str)
             for tagname, tagvalue in tags.items():
                 self.assertIsInstance(tagname, str)
                 self.assertIsInstance(tagvalue, str)
Exemple #2
0
    def test_correct_patientsname(self):
        for directory, expected_result in self.get_next_test_directory():
            tree = db.browse(directory)

            test_filename = os.path.join(directory,
                                         expected_result['Test Filename'])
            self.assertEqual(tree[test_filename]['Patient\'s Name'],
                             expected_result['Patient\'s Name'])
Exemple #3
0
    def test_can_filter_by_taglist(self):
        for directory, expected_result in self.get_next_test_directory():
            selected_tags = expected_result['Filter By Tags']
            tree = db.browse(directory, select_tags=selected_tags)
            test_filename = os.path.join(directory,
                                         expected_result['Test Filename'])

            available_tag_names = set(tree[test_filename].keys())
            expected_tag_names = set(selected_tags)

            self.assertSetEqual(available_tag_names, expected_tag_names)
Exemple #4
0
    def test_reads_tag_values_correctly(self):
        for directory, expected_result in self.get_next_test_directory():
            tree = db.browse(directory)

            test_filename = os.path.join(directory,
                                         expected_result['Test Filename'])
            for tag_name in ('Spacing Between Slices', 'Window Width',
                             'Patient\'s Age', 'Series Instance UID'):
                self.assertEqual(str(tree[test_filename][tag_name]),
                                 str(expected_result[tag_name]),
                                 msg="%s tag value incorrect" % tag_name)
Exemple #5
0
    def __init__(self, directory, select_tags):
        super(Model, self).__init__()
        self.directory = directory
        self.select_tags = select_tags
        self.viewmodels = []

        if select_tags is None or len(select_tags) < 1:
            raise AttributeError("Please specify at least one DICOM tag.")

        self.items = None
        try:
            self.items = browse(directory, select_tags=select_tags)

        except AttributeError:
            pass  # ignore if directory is emtpy or non-existent
Exemple #6
0
    def test_keeps_alphabetic_sorting(self):
        for directory, expected_result in self.get_next_test_directory():
            tree = db.browse(directory)

            self.assertListEqual(sorted(tree.keys()), list(tree.keys()))
Exemple #7
0
 def test_can_find_all_dicom_files_in_directory(self):
     for directory, expected_result in self.get_next_test_directory():
         tree = db.browse(directory)
         self.assertIsNotNone(tree)
         self.assertEqual(len(tree), expected_result['Number Of Files'])
Exemple #8
0
 def test_can_init_browser(self):
     for directory, expected_result in self.get_next_test_directory():
         tree = db.browse(directory)
         self.assertIsNotNone(tree)
         self.assertIsInstance(tree, dict)
Exemple #9
0
 def test_gently_throws_expection_if_directory_is_not_valid(self):
     for directory, expected_result in self.get_next_test_directory():
         with self.assertRaises(AttributeError):
             tree = db.browse('')  # directory is invalid on purpose
Exemple #10
0
 def test_gently_throws_exception_if_tag_name_is_not_valid(self):
     for directory, expected_result in self.get_next_test_directory():
         with self.assertRaises(AttributeError):
             tree = db.browse(directory,
                              select_tags=['SeriesTime'
                                           ])  # space omitted on purpose