예제 #1
0
 def test_get_hash(self):
     cm = CacheManager(self.workdir)
     hash1 = cm.getHash(self.src_path1)
     hash2 = cm.getHash(self.src_path2)
     self.assertEqual(hash1, '737b337e605199de28b3b64c674f9422')
     self.assertEqual(hash2, 'd5aa51d7fb180729089d2de904f7dffe')
     self.assertRaises(TypeError, cm.getHash)
     return
예제 #2
0
    def test_get_bucket_path_from_hash(self):
        cm = CacheManager(self.workdir)
        hash_val = cm.getHash(self.src_path1)
        path = cm._getBucketPathFromHash(hash_val)
        expected_path_end = os.path.join(
            '73', '737b337e605199de28b3b64c674f9422')
        self.assertEqual(os.listdir(self.workdir), [])
        self.assertTrue(path.endswith(expected_path_end))

        path = cm._getBucketPathFromHash('nonsense')
        self.assertEqual(path, None)
        return