FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(emulator): add support for storage emulator by Spirans · Pull Request #717 · firebase/firebase-admin-python · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) .py  (1) .yml  (1) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
run: |
npm install -g firebase-tools
firebase emulators:exec --only database --project fake-project-id 'pytest integration/test_db.py'
firebase emulators:exec --only storage --project fake-project-id 'pytest integration/test_storage.py --cert tests/data/service_account.json'

lint:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ First, install the Firebase CLI, then run:

```
firebase emulators:exec --only database --project fake-project-id 'pytest integration/test_db.py'
firebase emulators:exec --only storage --project fake-project-id 'pytest integration/test_storage.py --cert tests/data/service_account.json'
```

### Test Coverage
Expand Down
9 changes: 7 additions & 2 deletions firebase_admin/storage.py
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
# pylint: disable=import-error,no-name-in-module
try:
from google.cloud import storage
from google.cloud.storage._helpers import STORAGE_EMULATOR_ENV_VAR
except ImportError:
raise ImportError('Failed to import the Cloud Storage library for Python. Make sure '
'to install the "google-cloud-storage" module.')

from firebase_admin import _utils
import os

from firebase_admin import _utils

_STORAGE_ATTRIBUTE = '_storage'

Expand Down Expand Up @@ -61,7 +63,10 @@ def __init__(self, credentials, project, default_bucket):

@classmethod
def from_app(cls, app):
credentials = app.credential.get_credential()
if os.getenv(STORAGE_EMULATOR_ENV_VAR) is not None:
credentials = _utils.EmulatorAdminCredentials()
else:
credentials = app.credential.get_credential()
default_bucket = app.options.get('storageBucket')
# Specifying project ID is not required, but providing it when available
# significantly speeds up the initialization of the storage client.
Expand Down

Back | FazBrowse Home | New Git URL