This repository was archived by the owner on Jan 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ all: upload test
77test :
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
1313upload :
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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'
Original file line number Diff line number Diff line change 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 ))
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments