def test_posix_file_mod_time(self):
     """test the correct setting of a file mod time"""
     filepath = '/tmp/1234'
     mode = 'w'
     my_file = ExtendedFile(filepath, mode)
     my_file.close()
     my_file.set_mod_time(036)
     status = my_file.status()
     self.assertEqual(status.mtime, 036)
 def test_posix_file_status(self):
     """test the correct values of a files status"""
     filepath = '/tmp/1234'
     mode = 'w'
     my_file = ExtendedFile(filepath, mode)
     status = my_file.status()
     self.assertTrue(isinstance(status, PosixStatus))
     self.assertEqual(status.filesize, 0)
     self.assertEqual(status.file_storage_media, 'disk')
     my_file.close()
 def test_posix_file_stage(self):
     """test the correct staging of a posix file"""
     filepath = '/tmp/1234'
     mode = 'w'
     my_file = ExtendedFile(filepath, mode)
     my_file.stage()
     #easiest way to unit test is look at class variable
     # pylint: disable=protected-access
     self.assertTrue(my_file._staged)
     # pylint: enable=protected-access
     my_file.close()
Exemple #4
0
 def open(self, filepath, mode):
     """Open a posix file"""
     #want to close any open files first
     try:
         if self._file:
             self.close()
     except ArchiveInterfaceError as ex:
         err_str = "Can't close previous posix file before opening new "\
                   "one with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
     try:
         fpath = un_abs_path(filepath)
         filename = os.path.join(self._prefix, fpath)
         self._file = ExtendedFile(filename, mode)
         return self
     except Exception as ex:
         err_str = "Can't open posix file with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)