Example #1
0
 def setUp(self):
     file_fp, file_path = mkstemp()
     self.file_path = file_path
     stat = os.stat(self.file_path)
     self.file_attrs = {
         'pathname': os.path.basename(self.file_path),
         'size': stat.st_size,
         'ctime': int(time()),
         'mtime': stat.st_mtime,
         'mode': stat.st_mode,
     }
     self.file_object = FileEntry(**self.file_attrs)
     os.close(file_fp)
Example #2
0
 def test_from_dict(self):
     stat = os.stat(self.file_path)
     d = {
         'pathname': os.path.basename(self.file_path),
         'fs_pathname': os.path.basename(self.file_path),
         'size': stat.st_size,
         'ctime': int(time()),
         'mtime': stat.st_mtime,
         'mode': stat.st_mode,
         'digest': None,
         'isdir': False,
         'salt': None
     }
     file_object = FileEntry(**d)
     self.assertEqual(d, file_object.to_dict())
Example #3
0
 def test_from_dict(self):
     stat = os.stat(self.file_path)
     d = {
         'pathname': os.path.basename(self.file_path),
         'fs_pathname': os.path.basename(self.file_path),
         'size': stat.st_size,
         'ctime': int(time()),
         'mtime': stat.st_mtime,
         'mode': stat.st_mode,
         'digest': None,
         'isdir': False,
         'salt': None
     }
     file_object = FileEntry(**d)
     self.assertEqual(d, file_object.to_dict())
Example #4
0
 def setUp(self):
     file_fp, file_path = mkstemp()
     self.password = "******"
     self.crypto = Crypto(self.password)
     self.file_path = file_path
     self.file_entry = FileEntry.from_file(file_path, os.path.basename(file_path))
     os.close(file_fp)
Example #5
0
 def setUp(self):
     file_fp, file_path = mkstemp()
     self.password = '******'
     self.crypto = Crypto(self.password)
     self.file_path = file_path
     self.file_entry = FileEntry.from_file(file_path,
                                           os.path.basename(file_path))
     os.close(file_fp)
Example #6
0
 def setUp(self):
     file_fp, file_path = mkstemp()
     self.file_path = file_path
     stat = os.stat(self.file_path)
     self.file_attrs = {
         'pathname': os.path.basename(self.file_path),
         'size': stat.st_size,
         'ctime': int(time()),
         'mtime': stat.st_mtime,
         'mode': stat.st_mode,
     }
     self.file_object = FileEntry(**self.file_attrs)
     os.close(file_fp)
Example #7
0
 def test_from_file(self):
     stat = os.stat(self.file_path)
     d = {
         'pathname': os.path.basename(self.file_path),
         'fs_pathname': os.path.basename(self.file_path),
         'size': stat.st_size,
         'ctime': stat.st_ctime,
         'mtime': stat.st_mtime,
         'mode': stat.st_mode,
         'digest': file_hexlify_digest(self.file_path),
         'isdir': False,
         'salt': None
     }
     if is_windows:
         d['mode'] = None
     file_object = FileEntry.from_file(self.file_path, d['pathname'])
     self.assertEqual(d, file_object.to_dict())
Example #8
0
 def test_from_file(self):
     stat = os.stat(self.file_path)
     d = {
         'pathname': os.path.basename(self.file_path),
         'fs_pathname': os.path.basename(self.file_path),
         'size': stat.st_size,
         'ctime': stat.st_ctime,
         'mtime': stat.st_mtime,
         'mode': stat.st_mode,
         'digest': file_hexlify_digest(self.file_path),
         'isdir': False,
         'salt': None
     }
     if is_windows:
         d['mode'] = None
     file_object = FileEntry.from_file(self.file_path, d['pathname'])
     self.assertEqual(d, file_object.to_dict())
Example #9
0
class FileEntryTestCase(unittest.TestCase):
    def setUp(self):
        file_fp, file_path = mkstemp()
        self.file_path = file_path
        stat = os.stat(self.file_path)
        self.file_attrs = {
            'pathname': os.path.basename(self.file_path),
            'size': stat.st_size,
            'ctime': int(time()),
            'mtime': stat.st_mtime,
            'mode': stat.st_mode,
        }
        self.file_object = FileEntry(**self.file_attrs)
        os.close(file_fp)

    def tearDown(self):
        os.remove(self.file_path)

    def test_property(self):
        stat = os.stat(self.file_path)
        self.assertEqual(self.file_object.isdir, False)
        self.assertEqual(self.file_object.digest, None)
        self.assertEqual(self.file_object.size, stat.st_size)
        self.assertEqual(self.file_object.ctime, int(stat.st_ctime))
        self.assertEqual(self.file_object.mtime, stat.st_mtime)
        self.assertEqual(self.file_object.mode, stat.st_mode)
        self.assertEqual(self.file_object.pathname,
                         os.path.basename(self.file_path))

    def test_to_dict(self):
        d = self.file_object.to_dict()
        for k in self.file_attrs:
            self.assertEqual(d[k], self.file_attrs[k])

    def test_from_file(self):
        stat = os.stat(self.file_path)
        d = {
            'pathname': os.path.basename(self.file_path),
            'fs_pathname': os.path.basename(self.file_path),
            'size': stat.st_size,
            'ctime': stat.st_ctime,
            'mtime': stat.st_mtime,
            'mode': stat.st_mode,
            'digest': file_hexlify_digest(self.file_path),
            'isdir': False,
            'salt': None
        }
        if is_windows:
            d['mode'] = None
        file_object = FileEntry.from_file(self.file_path, d['pathname'])
        self.assertEqual(d, file_object.to_dict())

    def test_from_dict(self):
        stat = os.stat(self.file_path)
        d = {
            'pathname': os.path.basename(self.file_path),
            'fs_pathname': os.path.basename(self.file_path),
            'size': stat.st_size,
            'ctime': int(time()),
            'mtime': stat.st_mtime,
            'mode': stat.st_mode,
            'digest': file_digest(self.file_path),
            'isdir': False,
            'salt': None
        }
        file_object = FileEntry(**d)
        d['digest'] = hexlify(d['digest'])
        self.assertEqual(d, file_object.to_dict())
Example #10
0
 def setUp(self):
     file_fp, file_path = mkstemp()
     self.file_path = file_path
     self.file_entry = FileEntry.from_file(self.file_path, os.path.basename(
         self.file_path))
     os.close(file_fp)
Example #11
0
class FileEntryTestCase(unittest.TestCase):

    def setUp(self):
        file_fp, file_path = mkstemp()
        self.file_path = file_path
        stat = os.stat(self.file_path)
        self.file_attrs = {
            'pathname': os.path.basename(self.file_path),
            'size': stat.st_size,
            'ctime': int(time()),
            'mtime': stat.st_mtime,
            'mode': stat.st_mode,
        }
        self.file_object = FileEntry(**self.file_attrs)
        os.close(file_fp)

    def tearDown(self):
        os.remove(self.file_path)

    def test_property(self):
        stat = os.stat(self.file_path)
        self.assertEqual(self.file_object.isdir, False)
        self.assertEqual(self.file_object.digest, None)
        self.assertEqual(self.file_object.size, stat.st_size)
        self.assertEqual(self.file_object.ctime, int(stat.st_ctime))
        self.assertEqual(self.file_object.mtime, stat.st_mtime)
        self.assertEqual(self.file_object.mode, stat.st_mode)
        self.assertEqual(self.file_object.pathname,
                         os.path.basename(self.file_path))

    def test_to_dict(self):
        d = self.file_object.to_dict()
        for k in self.file_attrs:
            self.assertEqual(d[k], self.file_attrs[k])

    def test_from_file(self):
        stat = os.stat(self.file_path)
        d = {
            'pathname': os.path.basename(self.file_path),
            'fs_pathname': os.path.basename(self.file_path),
            'size': stat.st_size,
            'ctime': stat.st_ctime,
            'mtime': stat.st_mtime,
            'mode': stat.st_mode,
            'digest': file_hexlify_digest(self.file_path),
            'isdir': False,
            'salt': None
        }
        if is_windows:
            d['mode'] = None
        file_object = FileEntry.from_file(self.file_path, d['pathname'])
        self.assertEqual(d, file_object.to_dict())

    def test_from_dict(self):
        stat = os.stat(self.file_path)
        d = {
            'pathname': os.path.basename(self.file_path),
            'fs_pathname': os.path.basename(self.file_path),
            'size': stat.st_size,
            'ctime': int(time()),
            'mtime': stat.st_mtime,
            'mode': stat.st_mode,
            'digest': file_digest(self.file_path),
            'isdir': False,
            'salt': None
        }
        file_object = FileEntry(**d)
        d['digest'] = hexlify(d['digest'])
        self.assertEqual(d, file_object.to_dict())
Example #12
0
 def setUp(self):
     file_fp, file_path = mkstemp()
     self.file_path = file_path
     self.file_entry = FileEntry.from_file(self.file_path,
                                           os.path.basename(self.file_path))
     os.close(file_fp)