Пример #1
0
 def test_scan_label_quality(self):
     tmp_dir = tempfile.mkdtemp()
     repository = XnatRepo(
         project_id=self.project,
         server=SERVER, cache_dir=tmp_dir)
     tree = repository.tree(
         subject_ids=[self.SUBJECT],
         visit_ids=[self.VISIT])
     for accepted, expected in (
             (None, '1unusable'),
             ((None, 'questionable', 'usable'), '2unlabelled'),
             (('questionable', 'usable'), '3questionable'),
             ('usable', '4usable')):
         inpt = InputFilesets('dummy', order=0, valid_formats=text_format,
                              acceptable_quality=accepted)
         matched = inpt.match(tree).item(subject_id=self.SUBJECT,
                                         visit_id=self.VISIT)
         self.assertEqual(matched.name, expected)
Пример #2
0
 def test_cache_on_path_access(self):
     tmp_dir = tempfile.mkdtemp()
     repository = XnatRepo(
         project_id=self.project,
         server=SERVER, cache_dir=tmp_dir)
     tree = repository.tree(
         subject_ids=[self.SUBJECT],
         visit_ids=[self.VISIT])
     # Get a fileset
     fileset = list(list(list(tree.subjects)[0].sessions)[0].filesets)[0]
     fileset.format = text_format
     self.assertEqual(fileset._path, None)
     target_path = op.join(
         tmp_dir, self.project,
         '{}_{}'.format(self.project, self.SUBJECT),
         '{}_{}_{}'.format(self.project, self.SUBJECT, self.VISIT),
         fileset.basename, fileset.fname)
     # This should implicitly download the fileset
     self.assertEqual(fileset.path, target_path)
     with open(target_path) as f:
         self.assertEqual(f.read(),
                          self.INPUT_FILESETS[fileset.basename])