Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit cc6a826

Browse files
author
Jon Wayne Parrott
committed
Merge pull request #83 from GoogleCloudPlatform/new_e2e_tests
Adding e2e tests for supported APIs.
2 parents df0c203 + 7931e01 commit cc6a826

6 files changed

Lines changed: 82 additions & 1 deletion

File tree

tests/e2e/client/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ all: upload test
77
test:
88
virtualenv env
99
env/bin/pip install -r requirements.txt
10-
env/bin/python main.py https://${GCLOUD_PROJECT}.appspot.com/
10+
env/bin/python main.py http://${GCLOUD_PROJECT}.appspot.com/
1111

1212
.PHONY: upload
1313
upload:

tests/e2e/tests/logging_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from google.appengine.api.logservice import logservice
2+
import json
3+
import logging
4+
import os
5+
import pytest
6+
7+
8+
9+
@pytest.fixture
10+
def request_id():
11+
return os.environ.get('REQUEST_LOG_ID')
12+
13+
@pytest.mark.xfail
14+
def do_not_run_test_logservice_fetch(request_id):
15+
"""This test fails at logservice.fetch"""
16+
logging.info('TESTING')
17+
found_log = False
18+
for req_log in logservice.fetch(
19+
request_ids=[request_id],
20+
include_app_logs=True):
21+
for app_log in req_log.app_logs:
22+
if app_log.message == 'TESTING':
23+
found_log = True
24+
25+
assert found_log
26+

tests/e2e/tests/memcache_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from google.appengine.api import memcache
2+
import pytest
3+
import time
4+
5+
key1 = 'key1'
6+
data1 = 'data1'
7+
timeout = 2
8+
timeout_tolerance = 2
9+
10+
def test_memcache():
11+
assert memcache.get(key1) == None
12+
memcache.set(key1, data1)
13+
assert memcache.get(key1) == data1
14+
assert memcache.set(key1, data1, timeout)
15+
time.sleep(timeout + timeout_tolerance)
16+
assert memcache.get(key1) == None

tests/e2e/tests/search_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from google.appengine.api import search
2+
import pytest
3+
import time
4+
5+
@pytest.fixture
6+
def index():
7+
index = search.Index(name='simple-index', namespace='')
8+
doc = search.Document(doc_id='test_id', fields=[
9+
search.TextField(name='body', value='hello world'),
10+
])
11+
index.put(doc)
12+
return index
13+
14+
15+
def test_basic_search(index):
16+
resp = index.search('hello')
17+
assert len(resp.results) == 1
18+
result = resp.results[0]
19+
assert result.doc_id == 'test_id'
20+
assert result.language == 'en'
21+
assert result.fields[0].value == 'hello world'
22+
assert result.fields[0].name == 'body'

tests/e2e/tests/urlfetch_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from google.appengine.api import urlfetch
2+
import pytest
3+
import time
4+
5+
url = 'http://www.google.com'
6+
7+
def test_urlfetch():
8+
resp = urlfetch.fetch(url)
9+
assert resp.status_code == 200
10+
assert resp.headers['content-length'] == str(len(resp.content))

tests/e2e/tests/users_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from google.appengine.api import users
2+
import pytest
3+
4+
user = users.get_current_user()
5+
6+
def test_current_user():
7+
assert user == None

0 commit comments

Comments
 (0)