Exemple #1
0
    def test_iter_file_tree_chunk4(self):
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_set_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_file_tree_chunk4(self):
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_set_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())
        nose.tools.assert_set_equal(actual_filepaths, expected_filepaths)
Exemple #3
0
 def test_iter(self, m_open, m_pickle):
     expected_file_tree_iter = ['/a', '/b', '/d']
     dfs = DataFileSet('/')
     dfs._iter_file_tree = mock.MagicMock(
         return_value=expected_file_tree_iter)
     list(dfs)
     nose.tools.assert_equal(m_open.call_count, 3)
     nose.tools.assert_equal(m_pickle.load.call_count, 3)
     m_open.assert_any_call('/a')
     m_open.assert_any_call('/b')
     m_open.assert_any_call('/d')
Exemple #4
0
    def test_iter_file_tree_chunk0(self):
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_set_tree')
        expected_filepaths = {
            os.path.join(test_dir_path, 'UUID_0.dataElement'),
            os.path.join(test_dir_path, 'UUID_1.dataElement'),
            os.path.join(test_dir_path, 'UUID_2.dataElement'),
        }

        dfs = DataFileSet(test_dir_path, uuid_chunk=None, pickle_protocol=2)
        actual_filepaths = set(dfs._iter_file_tree())
        self.assertSetEqual(actual_filepaths, expected_filepaths)
Exemple #5
0
 def test_iter(self, m_open, m_pickle):
     expected_file_tree_iter = ['/a', '/b', '/d']
     dfs = DataFileSet('/')
     dfs._iter_file_tree = mock.MagicMock(
         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')
     m_open.assert_any_call('/b')
     m_open.assert_any_call('/d')
Exemple #6
0
    def test_iter_file_tree_chunk3(self):
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_set_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())
        nose.tools.assert_set_equal(actual_filepaths, expected_filepaths)
Exemple #7
0
    def test_iter_file_tree_chunk3(self):
        test_dir_path = os.path.join(TEST_DATA_DIR, 'test_data_file_set_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 #8
0
 def test_count(self):
     expected_file_tree_iter = ['/a', '/b', '/d']
     dfs = DataFileSet('/')
     dfs._iter_file_tree = mock.MagicMock(
         return_value=expected_file_tree_iter)
     nose.tools.assert_equal(dfs.count(), 3)
Exemple #9
0
 def test_count(self):
     expected_file_tree_iter = ['/a', '/b', '/d']
     dfs = DataFileSet('/')
     dfs._iter_file_tree = mock.MagicMock(
         return_value=expected_file_tree_iter)
     self.assertEqual(dfs.count(), 3)