def test_nobases(self): """Tests exception handling if build support urls are improperly specified.""" try: util = BinaryUtil(config=self.config_urls()) with util.select_binary_stream('bin/foo', '4.4.3', 'foo') as stream: self.fail('We should have gotten a "NoBaseUrlsError".') except BinaryUtil.NoBaseUrlsError as e: pass # expected
def test_nobases(self): """Tests exception handling if build support urls are improperly specified.""" try: util = BinaryUtil(config=self.config_urls()) with util.select_binary_stream('bin/foo', '4.4.3', 'foo') as stream: self.fail('We should have gotten a "NoBaseUrlsError".') except BinaryUtil.NoBaseUrlsError as e: pass # expected
def _seens_test(self, binaries, bases, reader, config=None): unseen = [item for item in reader.values() if item.startswith('SEEN ')] if not config: config = self.config_urls(bases) util = BinaryUtil(config=config) for key in binaries: base_path, version, name = binaries[key] with util.select_binary_stream(base_path, version, name, url_opener=reader) as stream: self.assertEqual(stream(), 'SEEN ' + key.upper()) unseen.remove(stream()) self.assertEqual(0, len(unseen)) # Make sure we've seen all the SEENs.
def _seens_test(self, binaries, bases, reader, config=None): unseen = [item for item in reader.values() if item.startswith('SEEN ')] if not config: config = self.config_urls(bases) util = BinaryUtil(config=config) for key in binaries: base_path, version, name = binaries[key] with util.select_binary_stream(base_path, version, name, url_opener=reader) as stream: self.assertEqual(stream(), 'SEEN ' + key.upper()) unseen.remove(stream()) self.assertEqual(0, len(unseen)) # Make sure we've seen all the SEENs.
def test_support_url_multi(self): """Tests to make sure existing base urls function as expected.""" config = self.config_urls([ 'BLATANTLY INVALID URL', 'https://pantsbuild.github.io/binaries/reasonably-invalid-url', 'https://pantsbuild.github.io/binaries/build-support', 'https://pantsbuild.github.io/binaries/build-support', # Test duplicate entry handling. 'https://pantsbuild.github.io/binaries/another-invalid-url', ]) binaries = [ ('bin/protobuf', '2.4.1', 'protoc',), ] util = BinaryUtil(config=config) for base_path, version, name in binaries: one = 0 with util.select_binary_stream(base_path, version, name) as stream: stream() one += 1 self.assertEqual(one, 1)
def test_support_url_multi(self): """Tests to make sure existing base urls function as expected.""" config = self.config_urls([ 'BLATANTLY INVALID URL', 'https://pantsbuild.github.io/binaries/reasonably-invalid-url', 'https://pantsbuild.github.io/binaries/build-support', 'https://pantsbuild.github.io/binaries/build-support', # Test duplicate entry handling. 'https://pantsbuild.github.io/binaries/another-invalid-url', ]) binaries = [ ('bin/protobuf', '2.4.1', 'protoc',), ] util = BinaryUtil(config=config) for base_path, version, name in binaries: one = 0 with util.select_binary_stream(base_path, version, name) as stream: stream() one += 1 self.assertEqual(one, 1)