예제 #1
0
파일: test_command.py 프로젝트: vdt/quilt
    def test_install_invalid_package(self):
        session = requests.Session()

        with assertRaisesRegex(self, command.CommandException, "owner/package_name"):
            command.install(session=session, package="no_user")
        with assertRaisesRegex(self, command.CommandException, "owner/package_name"):
            command.install(session=session, package="a/b/c")
예제 #2
0
 def test_install_invalid_package(self):
     with self.assertRaisesRegexp(command.CommandException,
                                  "owner/package_name"):
         command.install(Namespace(package="no_user"))
     with self.assertRaisesRegexp(command.CommandException,
                                  "owner/package_name"):
         command.install(Namespace(package="a/b/c"))
예제 #3
0
    def test_bad_object_hash(self):
        """
        Test that a package with a file hash mismatch fails installation.
        """
        tabledata = 'Bad package'
        h = hashlib.new(HASH_TYPE)
        h.update(tabledata.encode('utf-8'))
        obj_hash = 'e867010701edc0b1c8be177e02a93aa3cb1342bb1123046e1f6b40e428c6048e'
        contents = GroupNode(
            dict(foo=GroupNode(dict(bar=TableNode([obj_hash])))))
        contents_hash = hash_contents(contents)

        self._mock_tag('foo/bar', 'latest', contents_hash)
        self._mock_package('foo/bar', contents_hash, contents, [obj_hash])
        self._mock_s3(obj_hash, tabledata)

        with assertRaisesRegex(self, command.CommandException,
                               "Mismatched hash"):
            command.install('foo/bar')

        assert not os.path.exists('quilt_packages/foo/bar.json')
예제 #4
0
파일: test_install.py 프로젝트: vdt/quilt
    def test_install_latest(self):
        """
        Install the latest update of a package.
        """
        table_data = "table" * 10
        h = hashlib.new(HASH_TYPE)
        h.update(table_data.encode('utf-8'))
        table_hash = h.hexdigest()

        file_data = "file" * 10
        h = hashlib.new(HASH_TYPE)
        h.update(file_data.encode('utf-8'))
        file_hash = h.hexdigest()

        contents = GroupNode(
            dict(foo=GroupNode(
                dict(bar=TableNode([table_hash]), blah=FileNode([file_hash
                                                                 ])))))
        contents_hash = hash_contents(contents)

        self._mock_tag('foo/bar', 'latest', contents_hash)
        self._mock_package('foo/bar', contents_hash, contents,
                           [table_hash, file_hash])
        self._mock_s3(table_hash, table_data)
        self._mock_s3(file_hash, file_data)

        session = requests.Session()
        command.install(session, 'foo/bar')

        with open('quilt_packages/foo/bar.json') as fd:
            file_contents = json.load(fd, object_hook=decode_node)
            assert file_contents == contents

        with open('quilt_packages/objs/{hash}'.format(hash=table_hash)) as fd:
            contents = fd.read()
            assert contents == table_data

        with open('quilt_packages/objs/{hash}'.format(hash=file_hash)) as fd:
            contents = fd.read()
            assert contents == file_data
예제 #5
0
 def test_install_invalid_package(self):
     with assertRaisesRegex(self, command.CommandException,
                            "owner/package_name"):
         command.install(package="no_user")