8000 integration tests · fossabot/firebase-admin-python@0f8424e · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f8424e

Browse files
committed
integration tests
1 parent 8448e26 commit 0f8424e

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

firebase_admin/dynamic_links.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def __init__(self, **kwargs):
151151
raise ValueError('Invalid Count, must be a non negative int, "{}".'.format(count))
152152
self._count = int(count)
153153

154-
155154
@property
156155
def platform(self):
157156
return self._platform

integration/test_dynamic_links.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@ def test_unauthorized(self):
5353
'https://fake1.app.goo.gl/uQWc',
5454
dynamic_links.StatOptions(duration_days=4000))
5555
assert excinfo.value.code == 403
56+
57+
@pytest.mark.skipif(not dynamic_links_e2e_url,
58+
reason="End-to-end tests not set up, see CONTRIBTING.md file.")
59+
def test_bad_unauthorized(self):
60+
with pytest.raises(dynamic_links.ApiCallError) as excinfo:
61+
dynamic_links.get_link_stats(
62+
dynamic_links_e2e_url+"/too/many/slashes/in/shortlink",
63+
dynamic_links.StatOptions(duration_days=4000))
64+
assert excinfo.value.code == 400
65+
assert 'Request contains an invalid argument' in str(excinfo.value)

tests/test_dynamic_links.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,42 @@ def test_get_stats_error(self, dynamic_links_test):
106106
dynamic_links.get_link_stats(MOCK_SHORT_URL, options, app=dynamic_links_test.app)
107107
assert excinfo.value.code == 500
108108

109+
@pytest.mark.parametrize('error_code', [400, 401, 500])
110+
def test_server_error(self, dynamic_links_test, error_code):
111+
options = dynamic_links.StatOptions(duration_days=9)
112+
dynamic_links_test._instrument_dynamic_links(
113+
payload=json.dumps({'error': {
114+
'status': 'INTERNAL_ERROR',
115+
'message': 'json_test_error',
116+
'code': error_code}}),
117+
status=error_code)
118+
with pytest.raises(dynamic_links.ApiCallError) as excinfo:
119+
dynamic_links.get_link_stats(
120+
MOCK_SHORT_URL, options, app=dynamic_links_test.app)
121+
assert 'json_test_error' in str(excinfo.value)
122+
123+
@pytest.mark.parametrize('error_code', [400, 401, 500])
124+
def test_server_unformatted_error(self, dynamic_links_test, error_code):
125+
options = dynamic_links.StatOptions(duration_days=9)
126+
dynamic_links_test._instrument_dynamic_links(
127+
payload='custom error message',
128+
status=error_code)
129+
with pytest.raises(dynamic_links.ApiCallError) as excinfo:
130+
dynamic_links.get_link_stats(
131+
MOCK_SHORT_URL, options, app=dynamic_links_test.app)
132+
assert 'custom error message' in str(excinfo.value)
133+
134+
def test_server_none_error(self, dynamic_links_test):
135+
options = dynamic_links.StatOptions(duration_days=9)
136+
dynamic_links_test._instrument_dynamic_links(
137+
payload='',
138+
status=400)
139+
with pytest.raises(dynamic_links.ApiCallError) as excinfo:
140+
dynamic_links.get_link_stats(
141+
MOCK_SHORT_URL, options, app=dynamic_links_test.app)
142+
assert 'Unexpected HTTP response' in str(excinfo.value)
143+
144+
109145
@pytest.mark.parametrize('invalid_url', ['google.com'] + INVALID_STRINGS)
110146
def test_get_stats_invalid_url(self, dynamic_links_test, invalid_url):
111147
options = dynamic_links.StatOptions(duration_days=9)

0 commit comments

Comments
 (0)
0