Ejemplo n.º 1
0
    def test_external_url_generator(self):
        binary_util = self._gen_binary_util(baseurls=[])

        binary_request = BinaryRequest(
            supportdir='supportdir',
            version='version',
            name='name',
            platform_dependent=False,
            external_url_generator=ExternalUrlGenerator(),
            # TODO: test archiver!
            archiver=None)

        with self.assertRaises(BinaryUtil.BinaryResolutionError) as cm:
            binary_util.select(binary_request)
        the_raised_exception_message = str(cm.exception)

        self.assertIn(BinaryToolFetcher.BinaryNotFound.__name__,
                      the_raised_exception_message)
        expected_msg = (
            "Error resolving binary request BinaryRequest(supportdir=supportdir, version=version, "
            "name=name, platform_dependent=False, "
            "external_url_generator=ExternalUrlGenerator(<example __str__()>), archiver=None): "
            "Failed to fetch name binary from any source: (Failed to fetch binary from "
            "https://www.pantsbuild.org/some-binary: Fetch of https://www.pantsbuild.org/some-binary failed with "
            "status code 404, Failed to fetch binary from https://www.pantsbuild.org/same-binary: Fetch of "
            "https://www.pantsbuild.org/same-binary failed with status code 404)'"
        )
        self.assertIn(expected_msg, the_raised_exception_message)
Ejemplo n.º 2
0
    def test_disallowing_external_urls(self):
        binary_util = self._gen_binary_util(
            baseurls=[], allow_external_binary_tool_downloads=False)

        binary_request = binary_request = BinaryRequest(
            supportdir='supportdir',
            version='version',
            name='name',
            platform_dependent=False,
            external_url_generator=ExternalUrlGenerator(),
            # TODO: test archiver!
            archiver=None)

        with self.assertRaises(BinaryUtil.BinaryResolutionError) as cm:
            binary_util.select(binary_request)
        the_raised_exception_message = str(cm.exception)

        self.assertIn(BinaryUtil.NoBaseUrlsError.__name__,
                      the_raised_exception_message)
        expected_msg = (
            "Error resolving binary request BinaryRequest(supportdir=supportdir, version=version, "
            "name=name, platform_dependent=False, "
            "external_url_generator=ExternalUrlGenerator(<example __str__()>), archiver=None): "
            "--binaries-baseurls is empty.")
        self.assertIn(expected_msg, the_raised_exception_message)
Ejemplo n.º 3
0
 def _make_binary_request(self, version):
   return BinaryRequest(
     supportdir=self.get_support_dir(),
     version=version,
     name=self._name_to_fetch(),
     platform_dependent=self.platform_dependent,
     external_url_generator=self.get_external_url_generator(),
     archiver=self._get_archiver())