Exemple #1
0
    def test_iter_file_tree_chunk4(self) -> None:
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_tree')
        expected_filepaths = {
            os.path.join(test_dir_path, '4/3/2/1/UUID_43210.dataElement'),
        }

        dfs = DataFileSet(test_dir_path, uuid_chunk=5, pickle_protocol=2)
        actual_filepaths = set(dfs._iter_file_tree())
        self.assertSetEqual(actual_filepaths, expected_filepaths)
Exemple #2
0
 def test_iter(self, m_open: mock.MagicMock,
               m_pickle: mock.MagicMock) -> None:
     expected_file_tree_iter = ['/a', '/b', '/d']
     dfs = DataFileSet('/')
     dfs._iter_file_tree = mock.MagicMock(  # type: ignore
         return_value=expected_file_tree_iter)
     list(dfs)
     self.assertEqual(m_open.call_count, 3)
     self.assertEqual(m_pickle.load.call_count, 3)
     m_open.assert_any_call('/a', 'rb')
     m_open.assert_any_call('/b', 'rb')
     m_open.assert_any_call('/d', 'rb')
Exemple #3
0
    def test_iter_file_tree_chunk3(self) -> None:
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_tree')
        expected_filepaths = {
            os.path.join(test_dir_path, '0/0/UUID_000.dataElement'),
            os.path.join(test_dir_path, '0/0/UUID_001.dataElement'),
            os.path.join(test_dir_path, '0/1/UUID_012.dataElement'),
            os.path.join(test_dir_path, '1/8/UUID_180.dataElement'),
            os.path.join(test_dir_path, '3/1/UUID_317.dataElement'),
        }

        dfs = DataFileSet(test_dir_path, uuid_chunk=3, pickle_protocol=2)
        actual_filepaths = set(dfs._iter_file_tree())
        self.assertSetEqual(actual_filepaths, expected_filepaths)
Exemple #4
0
 def test_count(self) -> None:
     expected_file_tree_iter = ['/a', '/b', '/d']
     dfs = DataFileSet('/')
     dfs._iter_file_tree = mock.MagicMock(  # type: ignore
         return_value=expected_file_tree_iter)
     self.assertEqual(dfs.count(), 3)