Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5ce463e

Browse filesBrowse files
Ace Nassriengelke
andauthored
feat(functions/tips-gcp-apis): add tests (GoogleCloudPlatform#8792)
* feat(functions/tips-gcp-apis): add tests * Lint Co-authored-by: Charles Engelke <engelke@google.com>
1 parent cfa9a88 commit 5ce463e
Copy full SHA for 5ce463e

File tree

Expand file treeCollapse file tree

2 files changed

+42
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+42
-0
lines changed

‎functions/tips-gcp-apis/main_test.py

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the 'License');
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an 'AS IS' BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import json
16+
import os
17+
18+
import flask
19+
import pytest
20+
21+
import main
22+
23+
24+
# Create a fake "app" for generating test request contexts.
25+
@pytest.fixture(scope="module")
26+
def app():
27+
return flask.Flask(__name__)
28+
29+
30+
def test_publishes_message(app):
31+
data = json.dumps({
32+
'topic': os.getenv('FUNCTIONS_TOPIC')
33+
})
34+
35+
with app.test_request_context(
36+
data=data,
37+
content_type='application/json'
38+
):
39+
response = main.gcp_api_call(flask.request)
40+
assert response == '1 message published'
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flask==2.1.0
2+
pytest==7.0.1

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.