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 d5fb1ba

Browse filesBrowse files
author
Jon Wayne Parrott
committed
Adding tests for managed_vms/analytics. Fixes GoogleCloudPlatform#180 (GoogleCloudPlatform#350)
1 parent 48f9559 commit d5fb1ba
Copy full SHA for d5fb1ba

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+47
-0
lines changed

‎managed_vms/analytics/main_test.py

Copy file name to clipboard
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
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 re
16+
17+
import pytest
18+
import responses
19+
20+
21+
@pytest.fixture
22+
def app(monkeypatch):
23+
monkeypatch.setenv('GA_TRACKING_ID', '1234')
24+
25+
import main
26+
27+
main.app.testing = True
28+
return main.app.test_client()
29+
30+
31+
@responses.activate
32+
def test_tracking(app):
33+
responses.add(
34+
responses.POST,
35+
re.compile(r'.*'),
36+
body='{}',
37+
content_type='application/json')
38+
39+
r = app.get('/')
40+
41+
assert r.status_code == 200
42+
assert 'Event tracked' in r.data.decode('utf-8')
43+
44+
assert len(responses.calls) == 1
45+
request_body = responses.calls[0].request.body
46+
assert 'tid=1234' in request_body
47+
assert 'ea=test+action' in request_body

0 commit comments

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