Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/e2e/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ all: upload test
test:
virtualenv env
env/bin/pip install -r requirements.txt
env/bin/python main.py https://${GCLOUD_PROJECT}.appspot.com/
env/bin/python main.py http://${GCLOUD_PROJECT}.appspot.com/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not https?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown

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 of requests. ;)


.PHONY: upload
upload:
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/tests/logging_test.py
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():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use pytest.mark.xfail? https://pytest.org/latest/skipping.html

"""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

16 changes: 16 additions & 0 deletions tests/e2e/tests/memcache_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from google.appengine.api import memcache
import pytest
import time
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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
22 changes: 22 additions & 0 deletions tests/e2e/tests/search_test.py
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'
10 changes: 10 additions & 0 deletions tests/e2e/tests/urlfetch_test.py
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))
7 changes: 7 additions & 0 deletions tests/e2e/tests/users_test.py
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