Example #1
0
 def test_get_account_details_from_fs(self):
     td = tempfile.mkdtemp()
     tf = tarfile.open("plugins/data/container_tree.tar.bz2", "r:bz2")
     orig_cwd = os.getcwd()
     os.chdir(td)
     tf.extractall()
     try:
         cd = utils._get_container_details_from_fs(td)
         assert cd.bytes_used == 30, repr(cd.bytes_used)
         assert cd.object_count == 8, repr(cd.object_count)
         assert cd.obj_list == ['file1', 'file3', 'file2',
                                'dir3', 'dir1', 'dir2',
                                'dir1/file1', 'dir1/file2'
                                ], repr(cd.obj_list)
         full_dir1 = os.path.join(td, 'dir1')
         full_dir2 = os.path.join(td, 'dir2')
         full_dir3 = os.path.join(td, 'dir3')
         exp_dir_dict = { td:        os.path.getmtime(td),
                          full_dir1: os.path.getmtime(full_dir1),
                          full_dir2: os.path.getmtime(full_dir2),
                          full_dir3: os.path.getmtime(full_dir3),
                          }
         for d,m in cd.dir_list:
             assert d in exp_dir_dict
             assert exp_dir_dict[d] == m
     finally:
         os.chdir(orig_cwd)
         shutil.rmtree(td)
Example #2
0
 def test_get_container_details_from_fs_notadir(self):
     tf = tempfile.NamedTemporaryFile()
     cd = utils._get_container_details_from_fs(tf.name)
     assert cd.bytes_used == 0
     assert cd.object_count == 0
     assert cd.obj_list == []
     assert cd.dir_list == []