Created
January 24, 2020 17:48
-
-
Save franksands/65e5bcc56c56f678aa012281e1d5de22 to your computer and use it in GitHub Desktop.
list files in cloud store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import unittest | |
import cloudstorage | |
GOOGLE_APP_ENGINE_PATH = os.environ.get("GAE_PATH") | |
sys.path.append(GOOGLE_APP_ENGINE_PATH + 'lib/yaml-3.10') | |
from google.appengine.ext import testbed | |
class CloudStorageTestCase(unittest.TestCase): | |
@classmethod | |
def setUpClass(cls): | |
cls.testbed = testbed.Testbed() | |
cls.testbed.activate() | |
cls.testbed.init_app_identity_stub() | |
cls.testbed.init_memcache_stub() | |
cls.testbed.init_blobstore_stub() | |
cls.testbed.init_urlfetch_stub() | |
cls.testbed.init_datastore_v3_stub() | |
def test_list_files(self): | |
with cloudstorage.open('/default/test/test1.json', 'w', content_type='application/json') as fout: | |
fout.write('{"id": "test 1"}') | |
with cloudstorage.open('/default/test/test2.json', 'w', content_type='application/json') as fout: | |
fout.write('{"id": "test 2"}') | |
files = cloudstorage.listbucket('/default/test') | |
for file in files: | |
print file.filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment