Exemplo n.º 1
0
 def test_charm_base_inheritance(self):
     """
     get_sha256() should be implemented in the base class,
     and should use compute_sha256 to calculate the digest.
     """
     directory = CharmDirectory(self.sample_dir1)
     bundle = directory.as_bundle()
     digest = compute_file_hash(hashlib.sha256, bundle.path)
     self.assertEquals(digest, directory.get_sha256())
Exemplo n.º 2
0
 def test_charm_base_inheritance(self):
     """
     get_sha256() should be implemented in the base class,
     and should use compute_sha256 to calculate the digest.
     """
     directory = CharmDirectory(self.sample_dir1)
     bundle = directory.as_bundle()
     digest = compute_file_hash(hashlib.sha256, bundle.path)
     self.assertEquals(digest, directory.get_sha256())
Exemplo n.º 3
0
 def test_compute_sha256(self):
     """
     Computing the sha256 of a directory will use the bundled
     charm, since the hash of the file itself is needed.
     """
     directory = CharmDirectory(self.sample_dir1)
     sha256 = directory.compute_sha256()
     charm_bundle = directory.as_bundle()
     self.assertEquals(type(charm_bundle), CharmBundle)
     self.assertEquals(compute_file_hash(hashlib.sha256, charm_bundle.path),
                       sha256)
Exemplo n.º 4
0
 def test_compute_sha256(self):
     """
     Computing the sha256 of a directory will use the bundled
     charm, since the hash of the file itself is needed.
     """
     directory = CharmDirectory(self.sample_dir1)
     sha256 = directory.compute_sha256()
     charm_bundle = directory.as_bundle()
     self.assertEquals(type(charm_bundle), CharmBundle)
     self.assertEquals(compute_file_hash(hashlib.sha256,
                                         charm_bundle.path),
                       sha256)
Exemplo n.º 5
0
 def test_compute_file_hash(self):
     for type in (hashlib.sha256, hashlib.md5):
         filename = self.makeFile("content")
         digest = compute_file_hash(type, filename)
         self.assertEquals(digest, type("content").hexdigest())
Exemplo n.º 6
0
    def compute_sha256(self):
        """Return the SHA256 digest for this charm bundle.

        The digest is extracted out of the final bundle file itself.
        """
        return compute_file_hash(hashlib.sha256, self.path)
Exemplo n.º 7
0
 def get_charm_sha256(self):
     return compute_file_hash(hashlib.sha256, self.filename)
Exemplo n.º 8
0
    def compute_sha256(self):
        """Return the SHA256 digest for this charm bundle.

        The digest is extracted out of the final bundle file itself.
        """
        return compute_file_hash(hashlib.sha256, self.path)
Exemplo n.º 9
0
 def get_charm_sha256(self):
     return compute_file_hash(hashlib.sha256, self.filename)
Exemplo n.º 10
0
 def test_compute_file_hash(self):
     for type in (hashlib.sha256, hashlib.md5):
         filename = self.makeFile("content")
         digest = compute_file_hash(type, filename)
         self.assertEquals(digest, type("content").hexdigest())