Scrapy, a fast high-level web crawling & scraping framework for Python.
added test for gcs policy
rhoboro5254ac393bdf
diff --git a/scrapy/utils/test.py b/scrapy/utils/test.pyindex 60b931f48..4b935c51b 100644--- a/scrapy/utils/test.py+++ b/scrapy/utils/test.py@@ -57,8 +57,9 @@ def get_gcs_content_and_delete(bucket, path):bucket = client.get_bucket(bucket)blob = bucket.get_blob(path)content = blob.download_as_string()+ acl = list(blob.acl) # loads acl before it will be deletedbucket.delete_blob(path)- return content, blob+ return content, acl, blobdef get_crawler(spidercls=None, settings_dict=None):"""Return an unconfigured Crawler object. If settings_dict is given, itdiff --git a/tests/test_pipeline_files.py b/tests/test_pipeline_files.pyindex c761bd606..728a74803 100644--- a/tests/test_pipeline_files.py+++ b/tests/test_pipeline_files.py@@ -388,17 +388,20 @@ class TestGCSFilesStore(unittest.TestCase):meta = {'foo': 'bar'}path = 'full/filename'store = GCSFilesStore(uri)+ store.POLICY = 'authenticatedRead'+ expected_policy = {'role': 'READER', 'entity': 'allAuthenticatedUsers'}yield store.persist_file(path, buf, info=None, meta=meta, headers=None)s = yield store.stat_file(path, info=None)self.assertIn('last_modified', s)self.assertIn('checksum', s)self.assertEqual(s['checksum'], 'zc2oVgXkbQr2EQdSdw3OPA==')u = urlparse(uri)- content, blob = get_gcs_content_and_delete(u.hostname, u.path[1:]+path)+ content, acl, blob = get_gcs_content_and_delete(u.hostname, u.path[1:]+path)self.assertEqual(content, data)self.assertEqual(blob.metadata, {'foo': 'bar'})self.assertEqual(blob.cache_control, GCSFilesStore.CACHE_CONTROL)self.assertEqual(blob.content_type, 'application/octet-stream')+ self.assertIn(expected_policy, acl)class ItemWithFiles(Item):