Skip to content

Commit

Permalink
Test cleanup and Python 3.10 (#25)
Browse files Browse the repository at this point in the history
* Test cleanup

* Python 3.10

* actions/setup-python#177
  • Loading branch information
oittaa authored Mar 26, 2021
1 parent 8a797dd commit b7ca275
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, pypy-3.7]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy-3.7']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: '3.x'
- name: Install pypa/build
run: >-
python -m
Expand Down
23 changes: 10 additions & 13 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _get_storage_client(http):
"""Gets a python storage client"""
os.environ["STORAGE_EMULATOR_HOST"] = "http://localhost:9023"

# Cloud storage uses environment variables to configure api endpoints for
# Cloud Storage uses environment variables to configure API endpoints for
# file upload - which is read at module import time
from google.cloud import storage

Expand Down Expand Up @@ -44,7 +44,7 @@ def tearDownClass(cls):
def setUp(self):
self._session = requests.Session()
self._client = _get_storage_client(self._session)
ObjectsTests._server.wipe()
self._server.wipe()


class BucketsTests(BaseTestCase):
Expand All @@ -58,7 +58,7 @@ def tearDownClass(cls):
cls._server.stop()

def setUp(self):
BucketsTests._server.wipe()
self._server.wipe()
self._session = requests.Session()
self._client = _get_storage_client(self._session)

Expand Down Expand Up @@ -105,8 +105,7 @@ def test_bucket_delete_removes_file(self):
self.assertFalse(pwd.exists("bucket_name"))

def test_bucket_delete_non_existing(self):
# client.bucket doesn't create the actual bucket resource remotely,
# it only instantiate it in the local client
# client.bucket doesn't create the actual bucket resource remotely
bucket = self._client.bucket("bucket_name")
with self.assertRaises(NotFound):
bucket.delete()
Expand Down Expand Up @@ -135,8 +134,6 @@ def test_bucket_force_delete(self):
with fs.open_fs(STORAGE_BASE + STORAGE_DIR) as pwd:
self.assertFalse(pwd.exists("bucket_name"))

# TODO: test delete-force


class DefaultBucketTests(BaseTestCase):
def tearDown(self):
Expand Down Expand Up @@ -747,24 +744,24 @@ def test_download_by_url(self):

def test_download_by_dl_api_url(self):
""" Objects should be downloadable over HTTP from the emulator client. """
content = "Here is some content"
bucket = self._client.create_bucket("stillabucket")
content = "Here is some content 123"
bucket = self._client.create_bucket("bucket")
blob = bucket.blob("something.txt")
blob.upload_from_string(content)

url = self._url("/download/storage/v1/b/stillabucket/o/something.txt")
url = self._url("/download/storage/v1/b/bucket/o/something.txt")
response = requests.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, content.encode("utf-8"))

def test_download_by_api_media_url(self):
""" Objects should be downloadable over HTTP from the emulator client. """
content = "Here is some content"
bucket = self._client.create_bucket("newishbucket")
content = "Here is some content 456"
bucket = self._client.create_bucket("bucket")
blob = bucket.blob("something.txt")
blob.upload_from_string(content)

url = self._url("/storage/v1/b/newishbucket/o/something.txt")
url = self._url("/storage/v1/b/bucket/o/something.txt")
response = requests.get(url, params={"alt": "media"})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, content.encode("utf-8"))
Expand Down

0 comments on commit b7ca275

Please sign in to comment.