Esempio n. 1
0
    def test_register_blob(self):
        f_hash = fs.register_blob(self.root, self.path, self.stream, self.hash)
        self.assertEqual(len(f_hash), 40)

        test_path = fs.storage_root
        self.assertTrue(os.path.exists(test_path))
        test_path = os.path.join(test_path, self.root)
        self.assertTrue(os.path.exists(test_path))
        test_path = os.path.join(test_path, f_hash[:2])
        self.assertTrue(os.path.exists(test_path))
        test_path = os.path.join(test_path, f_hash[2:])
        self.assertTrue(os.path.exists(test_path))

        with open(test_path) as f:
            self.assertEqual(f.read(), self.data)
Esempio n. 2
0
 def test_hasher(self):
     data = os.urandom(64)
     with app.test_request_context('', method='PUT', data=data):
         s = stream.ChecksumCalcStream(request.stream)
         f_hash = fs.register_blob('root', 'f', s, s.hash)
         self.assertEqual(f_hash, hashlib.sha1(data).hexdigest())
Esempio n. 3
0
 def test_stat_blob(self):
     f_hash = fs.register_blob(self.root, self.path, self.stream, self.hash)
     mtime, fsize = fs.stat_blob(self.root, self.path, f_hash)
     self.assertIsNotNone(fsize)
     self.assertIsNotNone(mtime)
     self.assertEqual(fsize, len(self.data))
Esempio n. 4
0
 def test_retrieve_blob(self):
     f_hash = fs.register_blob(self.root, self.path, self.stream, self.hash)
     with fs.retrieve_blob_stream(self.root, f_hash) as s:
         self.assertEqual(s.read(), self.data)