Skip to content

Commit 4f0c232

Browse files
committed
Merge pull request #32 from GoogleCloudPlatform/e2e
Add e2e test
2 parents 59a80a7 + 36448cb commit 4f0c232

6 files changed

Lines changed: 107 additions & 0 deletions

File tree

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
## Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# # You may obtain a copy of the License at
5+
# #
6+
# # http://www.apache.org/licenses/LICENSE-2.0
7+
# #
8+
# # Unless required by applicable law or agreed to in writing, software
9+
# # distributed under the License is distributed on an "AS IS" BASIS,
10+
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# # See the License for the specific language governing permissions and
12+
# # limitations under the License.
13+
14+
.PHONY: e2e
15+
16+
VERSION=e2e-test
17+
18+
.PHONY: all
19+
all: deploy
20+
21+
.PHONY: deploy
22+
deploy:
23+
appcfg.py update . -A $(GAE_PROJECT) --version=$(VERSION)
24+
25+
.PHONY: e2e_test
26+
e2e_test: export GUESTBOOK_URL = http://$(VERSION)-dot-$(GAE_PROJECT).appspot.com
27+
e2e_test: deploy
28+
pip install -r e2e/requirements-dev.txt
29+
python e2e/test_e2e.py
30+

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,25 @@ High Replication Datastore (HRD) and retrieved using a strongly consistent
2828
[5]: http://webapp-improved.appspot.com/
2929
[6]: http://jinja.pocoo.org/docs/
3030
[7]: http://twitter.github.com/bootstrap/
31+
32+
33+
## E2E Test for this sample app
34+
35+
A Makefile is provided to deploy and run the e2e test.
36+
37+
To run:
38+
39+
export GAE_PROJECT=your-project-id
40+
make
41+
42+
To manually run, install the requirements
43+
44+
pip install -r e2e/requirements-dev.txt
45+
46+
Set the environment variable to point to your deployed app:
47+
48+
export GUESTBOOK_URL="http://guestbook-test-dot-useful-temple-118922.appspot.com/"
49+
50+
Finally, run the test
51+
52+
python e2e/test_e2e.py

e2e/README.md

Whitespace-only changes.

e2e/requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests==2.9.1

e2e/test_e2e.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2016 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import uuid
18+
import os
19+
import requests
20+
21+
URL = os.environ.get('GUESTBOOK_URL')
22+
23+
24+
def test_e2e():
25+
assert URL
26+
print ("Running test against {}".format(URL))
27+
r = requests.get(URL)
28+
assert b'Guestbook' in r.content
29+
u = uuid.uuid4()
30+
data = {'content': str(u)}
31+
r = requests.post(URL + '/sign', data)
32+
assert r.status_code == 200
33+
r = requests.get(URL)
34+
assert str(u).encode('utf-8') in r.content
35+
print("Success")
36+
37+
if __name__ == "__main__":
38+
test_e2e()

guestbook.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2016 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
117
# [START imports]
218
import os
319
import urllib

0 commit comments

Comments
 (0)