예제 #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.
     """
     sha256 = self.get_charm_sha256()
     bundle = CharmBundle(self.filename)
     self.assertEquals(bundle.get_sha256(), sha256)
예제 #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.
     """
     sha256 = self.get_charm_sha256()
     bundle = CharmBundle(self.filename)
     self.assertEquals(bundle.get_sha256(), sha256)
예제 #3
0
    def test_add_charm_and_publish(self):
        open_file_count = _count_open_files()
        yield self.publisher.add_charm(self.charm_id, self.charm)
        result = yield self.publisher.publish()
        self.assertEquals(_count_open_files(), open_file_count)

        children = yield self.client.get_children("/charms")
        self.assertEqual(children, [self.charm_key])
        fh = yield self.storage.get(self.charm_storage_key)
        bundle = CharmBundle(fh)
        self.assertEqual(self.charm.get_sha256(), bundle.get_sha256())

        self.assertEqual(
            result[0].bundle_url, "file://%s/%s" % (
                self.storage_dir, self.charm_storage_key))
예제 #4
0
    def test_charm_download(self):
        """Downloading a charm should store the charm locally."""
        yield self.unit_manager.download_charm(self.charm_state)
        checksum = self.charm.get_sha256()
        charm_id = local_charm_id(self.charm)
        charm_key = under.quote("%s:%s" % (charm_id, checksum))
        charm_path = os.path.join(self.unit_manager.charms_directory, charm_key)

        self.assertTrue(os.path.exists(charm_path))
        bundle = CharmBundle(charm_path)
        self.assertEquals(
            bundle.get_revision(), self.charm.get_revision())
        self.assertEquals(bundle.get_sha256(), checksum)
        self.assertIn(
            "Downloading charm %s" % charm_id, self.output.getvalue())
예제 #5
0
    def test_add_charm_and_publish(self):
        open_file_count = _count_open_files()
        yield self.publisher.add_charm(self.charm_id, self.charm)
        result = yield self.publisher.publish()
        self.assertEquals(_count_open_files(), open_file_count)

        children = yield self.client.get_children("/charms")
        self.assertEqual(children, [self.charm_key])
        fh = yield self.storage.get(self.charm_storage_key)
        bundle = CharmBundle(fh)
        self.assertEqual(self.charm.get_sha256(), bundle.get_sha256())

        self.assertEqual(
            result[0].bundle_url,
            "file://%s/%s" % (self.storage_dir, self.charm_storage_key))
예제 #6
0
    def test_charm_download(self):
        """
        Downloading a charm should store the charm locally.
        """
        yield self.agent.startService()
        yield self.agent.download_charm(self.charm_state)

        checksum = self.charm.get_sha256()
        charm_id = local_charm_id(self.charm)
        charm_key = under.quote("%s:%s" % (charm_id, checksum))
        charm_path = os.path.join(self.agent.charms_directory, charm_key)

        self.assertTrue(os.path.exists(charm_path))
        bundle = CharmBundle(charm_path)
        self.assertEquals(bundle.get_revision(), self.charm.get_revision())
        self.assertEquals(bundle.get_sha256(), checksum)
        self.assertIn("Downloading charm %s" % charm_id,
                      self.output.getvalue())
예제 #7
0
파일: test_charm.py 프로젝트: mcclurmc/juju
    def test_charm_download_file(self):
        """Downloading a charm should store the charm locally.
        """
        charm, charm_state = yield self.publish_charm()
        charm_directory = self.makeDir()

        # Download the charm
        yield download_charm(self.client, charm_state.id, charm_directory)

        # Verify the downloaded copy
        checksum = charm.get_sha256()
        charm_id = local_charm_id(charm)
        charm_key = under.quote("%s:%s" % (charm_id, checksum))
        charm_path = os.path.join(charm_directory, charm_key)

        self.assertTrue(os.path.exists(charm_path))
        bundle = CharmBundle(charm_path)
        self.assertEquals(bundle.get_revision(), charm.get_revision())

        self.assertEqual(checksum, bundle.get_sha256())
예제 #8
0
    def test_charm_download_file(self):
        """Downloading a charm should store the charm locally.
        """
        charm, charm_state = yield self.publish_charm()
        charm_directory = self.makeDir()

        # Download the charm
        yield download_charm(
            self.client, charm_state.id, charm_directory)

        # Verify the downloaded copy
        checksum = charm.get_sha256()
        charm_id = local_charm_id(charm)
        charm_key = under.quote("%s:%s" % (charm_id, checksum))
        charm_path = os.path.join(charm_directory, charm_key)

        self.assertTrue(os.path.exists(charm_path))
        bundle = CharmBundle(charm_path)
        self.assertEquals(bundle.get_revision(), charm.get_revision())

        self.assertEqual(checksum, bundle.get_sha256())
예제 #9
0
 def test_file_handle_as_path(self):
     sha256 = self.get_charm_sha256()
     fh = open(self.filename)
     bundle = CharmBundle(fh)
     self.assertEquals(bundle.get_sha256(), sha256)
예제 #10
0
 def test_file_handle_as_path(self):
     sha256 = self.get_charm_sha256()
     fh = open(self.filename)
     bundle = CharmBundle(fh)
     self.assertEquals(bundle.get_sha256(), sha256)