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+ """E2E test for logging API.
2+
3+ Currently DOES NOT work.
4+ """
5+ import json
6+ import logging
7+ import os
8+ import pytest
9+
10+ from google .appengine .api .logservice import logservice
11+
12+
13+ @pytest .fixture
14+ def request_id ():
15+ return os .environ .get ('REQUEST_LOG_ID' )
16+
17+ def test_log (request_id ):
18+ logging .info ('TESTING' )
19+
20+
21+ # This test must happen after test_log.
22+ def do_not_run_test_logservice_fetch (request_id ):
23+ """This test fails at logservice.fetch"""
24+ found_log = False
25+ for req_log in logservice .fetch (
26+ request_ids = [request_id ],
27+ include_app_logs = True ):
28+ for app_log in req_log .app_logs :
29+ if app_log .message == 'TESTING' :
30+ found_log = True
31+
32+ assert found_log
33+
Original file line number Diff line number Diff line change 1+ """Tests for the memcache API.
2+
3+ This test module is incomplete but is a starter.
4+ """
5+
6+ import pytest
7+ import time
8+
9+ from google .appengine .api import memcache
10+
11+
12+ @pytest .fixture
13+ def defaults ():
14+ memcache .flush_all ()
15+ return {
16+ 'client' : memcache ._CLIENT ,
17+ 'mapping' : {
18+ 'key1' , 'data1' ,
19+ 'key2' , 'data2' ,
20+ 'key3' , 'data3' ,
21+ },
22+ 'timeout' : 2 ,
23+ 'timeout_tolerance' : 2 ,
24+ 'namespace1' : 'foo' ,
25+ 'namespace2' : 'bar' ,
26+ 'default_range' : 10 ,
27+ 'default_incr_start' : 1 ,
28+ 'default_decr_start' : 1000 ,
29+ 'default_delta' : 10 ,
30+ }
31+
32+
33+ def test_memcache (defaults ):
34+ assert memcache .get ('key1' ) == None
35+ memcache .set ('key1' , 'data1' )
36+ assert memcache .get ('key1' ) == 'data1'
37+ assert memcache .set ('key1' , 'data1' , defaults ['timeout' ])
38+ time .sleep (defaults ['timeout' ] + defaults ['timeout_tolerance' ])
39+ assert memcache .get ('key1' ) == None
Original file line number Diff line number Diff line change 1+ """Tests for the search API.
2+
3+ This test module is incomplete but is a starter.
4+ """
5+
6+ import pytest
7+ import time
8+
9+ from google .appengine .api import search
10+
11+
12+ @pytest .fixture
13+ def index ():
14+ index = search .Index (name = 'simple-index' , namespace = '' )
15+ doc = search .Document (doc_id = 'test_id' , fields = [
16+ search .TextField (name = 'body' , value = 'hello world' ),
17+ ])
18+ index .put (doc )
19+ return index
20+
21+
22+ def test_basic_search (index ):
23+ resp = index .search ('hello' )
24+ assert len (resp .results ) == 1
25+ result = resp .results [0 ]
26+ assert result .doc_id == 'test_id'
27+ assert result .language == 'en'
28+ assert result .fields [0 ].value == 'hello world'
29+ assert result .fields [0 ].name == 'body'
Original file line number Diff line number Diff line change 1+ """Tests for the urlfetch API."""
2+
3+ import pytest
4+ import time
5+
6+ from google .appengine .api import urlfetch
7+
8+
9+ @pytest .fixture
10+ def url ():
11+ return 'http://www.google.com'
12+
13+ def test_urlfetch (url ):
14+ resp = urlfetch .fetch (url )
15+ assert resp .status_code == 200
16+ assert resp .headers ['content-length' ] == str (len (resp .content ))
Original file line number Diff line number Diff line change 1+ """E2E test for Users API."""
2+ import pytest
3+
4+ from google .appengine .api import users
5+
6+
7+ @pytest .fixture
8+ def user ():
9+ return users .get_current_user ()
10+
11+ def test_current_user (user ):
12+ assert user == None
You can’t perform that action at this time.
0 commit comments