-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from jeffmendoza/tests
Add test for some samples.
- Loading branch information
Showing
14 changed files
with
162 additions
and
94 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2015 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# from the app main.py | ||
from appengine.memcache.guestbook import main | ||
from tests import DatastoreTestbedCase | ||
|
||
import webapp2 | ||
|
||
|
||
class TestHandlers(DatastoreTestbedCase): | ||
def test_hello(self): | ||
# Build a request object passing the URI path to be tested. | ||
# You can also pass headers, query arguments etc. | ||
request = webapp2.Request.blank('/') | ||
# Get a response for that request. | ||
response = request.get_response(main.app) | ||
|
||
# Let's check if the response is correct. | ||
self.assertEqual(response.status_int, 200) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2015 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# from the app main.py | ||
from datastore.ndb.overview import main | ||
|
||
from tests import DatastoreTestbedCase | ||
|
||
import webapp2 | ||
|
||
|
||
class TestHandlers(DatastoreTestbedCase): | ||
def test_hello(self): | ||
# Build a request object passing the URI path to be tested. | ||
# You can also pass headers, query arguments etc. | ||
request = webapp2.Request.blank('/') | ||
# Get a response for that request. | ||
response = request.get_response(main.app) | ||
|
||
# Let's check if the response is correct. | ||
self.assertEqual(response.status_int, 200) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright 2015 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# from the app main.py | ||
from datastore.ndb.transactions import main | ||
|
||
from tests import DatastoreTestbedCase | ||
|
||
|
||
class TestHandlers(DatastoreTestbedCase): | ||
def setUp(self): | ||
super(TestHandlers, self).setUp() | ||
self.testbed.init_taskqueue_stub() | ||
main.app.config['TESTING'] = True | ||
self.app = main.app.test_client() | ||
|
||
def test_hello(self): | ||
rv = self.app.get('/') | ||
self.assertIn('Permenant note page', rv.data) | ||
self.assertEqual(rv.status, '200 OK') | ||
|
||
def test_post(self): | ||
rv = self.app.post('/add', data=dict( | ||
note_title='Title', | ||
note_text='Text' | ||
), follow_redirects=True) | ||
self.assertEqual(rv.status, '200 OK') | ||
|
||
def test_post2(self): | ||
rv = self.app.post('/add', data=dict( | ||
note_title='Title2', | ||
note_text='Text' | ||
), follow_redirects=True) | ||
self.assertEqual(rv.status, '200 OK') | ||
|
||
def test_post3(self): | ||
rv = self.app.post('/add', data=dict( | ||
note_title='Title3', | ||
note_text='Text' | ||
), follow_redirects=True) | ||
self.assertEqual(rv.status, '200 OK') | ||
|
||
def test_there(self): | ||
rv = self.app.post('/add', data=dict( | ||
note_title='Title', | ||
note_text='New' | ||
), follow_redirects=True) | ||
rv = self.app.post('/add', data=dict( | ||
note_title='Title', | ||
note_text='There' | ||
), follow_redirects=True) | ||
self.assertIn('Already there', rv.data) | ||
self.assertEqual(rv.status, '200 OK') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters