コード例 #1
0
ファイル: test_command.py プロジェクト: vdt/quilt
    def test_push_invalid_package(self):
        session = requests.Session()

        with assertRaisesRegex(self, command.CommandException, "owner/package_name"):
            command.push(session=session, package="no_user")
        with assertRaisesRegex(self, command.CommandException, "owner/package_name"):
            command.push(session=session, package="a/b/c")
コード例 #2
0
ファイル: test_push.py プロジェクト: diethardsteiner/quilt
    def test_push_subpackage(self):
        mydir = os.path.dirname(__file__)
        build_path = os.path.join(mydir, './build.yml')
        command.build('foo/bar', build_path)

        _, pkgroot = store.PackageStore.find_package(None, 'foo', 'bar')
        contents = pkgroot.children['dataframes']

        all_hashes = set(find_object_hashes(contents))
        upload_urls = {
            blob_hash:
            dict(head="https://example.com/head/{owner}/{hash}".format(
                owner='foo', hash=blob_hash),
                 put="https://example.com/put/{owner}/{hash}".format(
                     owner='foo', hash=blob_hash))
            for blob_hash in all_hashes
        }

        for blob_hash in all_hashes:
            urls = upload_urls[blob_hash]

            self.requests_mock.add(responses.HEAD, urls['head'], status=404)
            self.requests_mock.add(responses.PUT, urls['put'])

        self._mock_update_package('foo/bar', 'dataframes', contents,
                                  upload_urls)

        # Push a subpackage.
        command.push('foo/bar/dataframes')
コード例 #3
0
 def test_push_invalid_package(self):
     with self.assertRaisesRegexp(command.CommandException,
                                  "owner/package_name"):
         command.push(Namespace(package="no_user"))
     with self.assertRaisesRegexp(command.CommandException,
                                  "owner/package_name"):
         command.push(Namespace(package="a/b/c"))
コード例 #4
0
ファイル: test_push.py プロジェクト: vanzaj/quilt
    def test_push(self):
        mydir = os.path.dirname(__file__)
        build_path = os.path.join(mydir, './build_simple.yml')
        command.build('foo/bar', build_path)

        pkg_obj = store.PackageStore.find_package('foo', 'bar')
        pkg_hash = pkg_obj.get_hash()
        assert pkg_hash
        contents = pkg_obj.get_contents()
        urls = upload_urls(contents)
        for url in urls.values():
            self._mock_s3(url)

        self._mock_put_package('foo/bar', pkg_hash, contents)
        self._mock_put_tag('foo/bar', 'latest')

        command.push('foo/bar')
コード例 #5
0
    def test_push(self):
        mydir = os.path.dirname(__file__)
        build_path = os.path.join(mydir, './build_simple.yml')
        command.build('foo/bar', build_path)

        pkg_obj = store.PackageStore.find_package('foo', 'bar')
        pkg_hash = pkg_obj.get_hash()
        assert pkg_hash
        contents = pkg_obj.get_contents()

        all_hashes = set(find_object_hashes(contents))
        upload_urls = {
            blob_hash:
            dict(head="https://example.com/head/{owner}/{hash}".format(
                owner='foo', hash=blob_hash),
                 put="https://example.com/put/{owner}/{hash}".format(
                     owner='foo', hash=blob_hash))
            for blob_hash in all_hashes
        }

        # We will push the package twice, so we're mocking all responses twice.

        for blob_hash in all_hashes:
            urls = upload_urls[blob_hash]

            # First time the package is pushed, s3 HEAD 404s, and we get a PUT.
            self.requests_mock.add(responses.HEAD, urls['head'], status=404)
            self.requests_mock.add(responses.PUT, urls['put'])

            # Second time, s3 HEAD succeeds, and we're not expecting a PUT.
            self.requests_mock.add(responses.HEAD, urls['head'])

        self._mock_put_package('foo/bar', pkg_hash, upload_urls)
        self._mock_put_tag('foo/bar', 'latest')

        self._mock_put_package('foo/bar', pkg_hash, upload_urls)
        self._mock_put_tag('foo/bar', 'latest')

        # Push a new package.
        command.push('foo/bar')

        # Push it again; this time, we're verifying that there are no s3 uploads.
        command.push('foo/bar')
コード例 #6
0
ファイル: test_command.py プロジェクト: vdt/quilt
    def test_push_missing_package(self):
        session = requests.Session()

        with assertRaisesRegex(self, command.CommandException, "not found"):
            command.push(session=session, package="owner/package")
コード例 #7
0
 def test_push_missing_package(self):
     with assertRaisesRegex(self, command.CommandException, "not found"):
         command.push(package="owner/package")
コード例 #8
0
 def test_push_missing_package(self):
     with self.assertRaisesRegexp(command.CommandException, "not found"):
         command.push(Namespace(package="owner/package"))