-
Notifications
You must be signed in to change notification settings - Fork 26
Adding e2e tests for supported APIs. #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from google.appengine.api.logservice import logservice | ||
| import json | ||
| import logging | ||
| import os | ||
| import pytest | ||
|
|
||
|
|
||
|
|
||
| @pytest.fixture | ||
| def request_id(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this fixture probably isn't necessary unless you plan to add a lot more tests that do this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll leave this fixture here. Other tests I agree they're overkill, but this one is dependent per-request and if we ever upgrade our test harness to be able to test multiple requests this will be useful. |
||
| return os.environ.get('REQUEST_LOG_ID') | ||
|
|
||
| @pytest.mark.xfail | ||
| def do_not_run_test_logservice_fetch(request_id): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you just use |
||
| """This test fails at logservice.fetch""" | ||
| logging.info('TESTING') | ||
| found_log = False | ||
| for req_log in logservice.fetch( | ||
| request_ids=[request_id], | ||
| include_app_logs=True): | ||
| for app_log in req_log.app_logs: | ||
| if app_log.message == 'TESTING': | ||
| found_log = True | ||
|
|
||
| assert found_log | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from google.appengine.api import memcache | ||
| import pytest | ||
| import time | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. standard library imports go above third-party imports in a separate section. (I need to setup linting for tests) |
||
|
|
||
| key1 = 'key1' | ||
| data1 = 'data1' | ||
| timeout = 2 | ||
| timeout_tolerance = 2 | ||
|
|
||
| def test_memcache(): | ||
| assert memcache.get(key1) == None | ||
| memcache.set(key1, data1) | ||
| assert memcache.get(key1) == data1 | ||
| assert memcache.set(key1, data1, timeout) | ||
| time.sleep(timeout + timeout_tolerance) | ||
| assert memcache.get(key1) == None | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from google.appengine.api import search | ||
| import pytest | ||
| import time | ||
|
|
||
| @pytest.fixture | ||
| def index(): | ||
| index = search.Index(name='simple-index', namespace='') | ||
| doc = search.Document(doc_id='test_id', fields=[ | ||
| search.TextField(name='body', value='hello world'), | ||
| ]) | ||
| index.put(doc) | ||
| return index | ||
|
|
||
|
|
||
| def test_basic_search(index): | ||
| resp = index.search('hello') | ||
| assert len(resp.results) == 1 | ||
| result = resp.results[0] | ||
| assert result.doc_id == 'test_id' | ||
| assert result.language == 'en' | ||
| assert result.fields[0].value == 'hello world' | ||
| assert result.fields[0].name == 'body' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from google.appengine.api import urlfetch | ||
| import pytest | ||
| import time | ||
|
|
||
| url = 'http://www.google.com' | ||
|
|
||
| def test_urlfetch(): | ||
| resp = urlfetch.fetch(url) | ||
| assert resp.status_code == 200 | ||
| assert resp.headers['content-length'] == str(len(resp.content)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from google.appengine.api import users | ||
| import pytest | ||
|
|
||
| user = users.get_current_user() | ||
|
|
||
| def test_current_user(): | ||
| assert user == None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not https?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generates an annoying error. Can chat offline. Has to do with SSL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it requests/urllib3 screaming? If so, we just need to do
pip install requests[security]instead ofrequests. ;)