-
Notifications
You must be signed in to change notification settings - Fork 331
/
Copy pathtest_storage.py
52 lines (42 loc) · 1.56 KB
/
test_storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for firebase_admin.storage."""
import pytest
import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage
from tests import testutils
def setup_module():
cred = credentials.Certificate(testutils.resource_filename('service_account.json'))
firebase_admin.initialize_app(cred)
def teardown_module():
testutils.cleanup_apps()
def test_invalid_config():
with pytest.raises(ValueError):
storage.bucket()
@pytest.mark.parametrize('name', [None, '', 0, 1, True, False, list(), tuple(), dict()])
def test_invalid_name(name):
with pytest.raises(ValueError):
storage.bucket(name)
def test_valid_name():
# Should not make RPC calls.
bucket = storage.bucket('foo')
assert bucket is not None
assert bucket.name == 'foo'
def test_valid_name_with_explicit_app():
# Should not make RPC calls.
app = firebase_admin.get_app()
bucket = storage.bucket('foo', app=app)
assert bucket is not None
assert bucket.name == 'foo'