diff --git a/.coveragerc b/.coveragerc index d312cd95450..5a6f23dafbb 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,3 +10,4 @@ include = [report] exclude_lines = pragma: NO COVER + if __name__ == '__main__': diff --git a/appengine/images/tests/test_guestbook.py b/appengine/images/tests/test_guestbook.py index 6daa09dec32..dd07ca79f8c 100644 --- a/appengine/images/tests/test_guestbook.py +++ b/appengine/images/tests/test_guestbook.py @@ -28,6 +28,12 @@ def setUp(self): reload(main) def test_get(self): + main.Greeting( + parent=main.guestbook_key('default_guestbook'), + author='123', + content='abc' + ).put() + # Build a request object passing the URI path to be tested. # You can also pass headers, query arguments etc. request = webapp2.Request.blank('/') @@ -43,7 +49,7 @@ def test_post(self, mock_images): request = webapp2.Request.blank( '/sign', POST={'content': 'asdf'}, - ) + ) response = request.get_response(main.app) mock_images.resize.assert_called_once_with(mock.ANY, 32, 32) @@ -53,10 +59,11 @@ def test_post(self, mock_images): def test_img(self): greeting = main.Greeting( parent=main.guestbook_key('default_guestbook'), - id=123, + id=123 ) greeting.author = 'asdf' greeting.content = 'asdf' + greeting.avatar = b'123' greeting.put() request = webapp2.Request.blank( @@ -79,7 +86,7 @@ def test_post_and_get(self, mock_images): request = webapp2.Request.blank( '/sign', POST={'content': 'asdf'}, - ) + ) response = request.get_response(main.app) request = webapp2.Request.blank('/') diff --git a/appengine/localtesting/test_datastore.py b/appengine/localtesting/test_datastore.py index 512d32e6332..8a505d05b1a 100644 --- a/appengine/localtesting/test_datastore.py +++ b/appengine/localtesting/test_datastore.py @@ -47,7 +47,7 @@ def GetEntityViaMemcache(entity_key): # [START datastore_example_test] -class DatstoreTestCase(unittest.TestCase): +class DatastoreTestCase(unittest.TestCase): def setUp(self): # First, create an instance of the Testbed class. diff --git a/blog/__init__.py b/blog/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/blog/introduction-to-data-models-in-cloud-datastore/README.md b/blog/introduction_to_data_models_in_cloud_datastore/README.md similarity index 90% rename from blog/introduction-to-data-models-in-cloud-datastore/README.md rename to blog/introduction_to_data_models_in_cloud_datastore/README.md index 1620f5dc016..a94f51f3949 100644 --- a/blog/introduction-to-data-models-in-cloud-datastore/README.md +++ b/blog/introduction_to_data_models_in_cloud_datastore/README.md @@ -1,7 +1,7 @@ # Introduction to data models in Cloud Datastore This sample code is used in [this blog post](). It demonstrates two data models -using [Google Cloud Datstore](https://cloud.google.com/datastore). +using [Google Cloud Datastore](https://cloud.google.com/datastore). ## Prerequisites diff --git a/blog/introduction_to_data_models_in_cloud_datastore/__init__.py b/blog/introduction_to_data_models_in_cloud_datastore/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/blog/introduction-to-data-models-in-cloud-datastore/blog.py b/blog/introduction_to_data_models_in_cloud_datastore/blog.py similarity index 100% rename from blog/introduction-to-data-models-in-cloud-datastore/blog.py rename to blog/introduction_to_data_models_in_cloud_datastore/blog.py diff --git a/blog/introduction-to-data-models-in-cloud-datastore/requirements.txt b/blog/introduction_to_data_models_in_cloud_datastore/requirements.txt similarity index 100% rename from blog/introduction-to-data-models-in-cloud-datastore/requirements.txt rename to blog/introduction_to_data_models_in_cloud_datastore/requirements.txt diff --git a/blog/introduction-to-data-models-in-cloud-datastore/test_blog.py b/blog/introduction_to_data_models_in_cloud_datastore/test_blog.py similarity index 97% rename from blog/introduction-to-data-models-in-cloud-datastore/test_blog.py rename to blog/introduction_to_data_models_in_cloud_datastore/test_blog.py index f1e866f9150..f3042700deb 100644 --- a/blog/introduction-to-data-models-in-cloud-datastore/test_blog.py +++ b/blog/introduction_to_data_models_in_cloud_datastore/test_blog.py @@ -11,9 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from blog import main from tests import CloudBaseTest +from .blog import main + class BlogTestCase(CloudBaseTest): """Simple test case that ensures the blog code doesn't throw any errors.""" diff --git a/blog/introduction_to_data_models_in_cloud_datastore/test_wiki.py b/blog/introduction_to_data_models_in_cloud_datastore/test_wiki.py new file mode 100644 index 00000000000..19a850e8eb9 --- /dev/null +++ b/blog/introduction_to_data_models_in_cloud_datastore/test_wiki.py @@ -0,0 +1,23 @@ +# Copyright 2015, Google, Inc. +# 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 tests import CloudBaseTest + +from .wiki import main + + +class WikiTestCase(CloudBaseTest): + """Simple test case that ensures the wiki code doesn't throw any errors.""" + + def test_main(self): + main(self.constants['projectId']) diff --git a/blog/introduction-to-data-models-in-cloud-datastore/wiki.py b/blog/introduction_to_data_models_in_cloud_datastore/wiki.py similarity index 100% rename from blog/introduction-to-data-models-in-cloud-datastore/wiki.py rename to blog/introduction_to_data_models_in_cloud_datastore/wiki.py diff --git a/datastore/README.md b/datastore/README.md index 53711bb146e..ebea408ecfa 100644 --- a/datastore/README.md +++ b/datastore/README.md @@ -5,3 +5,4 @@ This section contains samples for [Google Cloud Datastore](https://cloud.google. ## Other Samples * [Google App Engine & NDB](../appengine/ndb). +* [Blog Sample: Introduction to Data Models in Cloud Datastore](../blog/introduction_to_data_models_in_cloud_datastore). diff --git a/storage/tests/test_compose_objects.py b/storage/tests/test_compose_objects.py new file mode 100644 index 00000000000..d9ca356904c --- /dev/null +++ b/storage/tests/test_compose_objects.py @@ -0,0 +1,29 @@ +# Copyright 2015, Google, Inc. +# 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. +# +import os + +from storage.compose_objects import main +from tests import CloudBaseTest + + +class TestComposeObjects(CloudBaseTest): + def test_main(self): + args = [ + 'ignored_command_name', + self.constants['bucketName'], + 'dest.txt', + os.path.join(self.resource_path, 'file1.txt'), + os.path.join(self.resource_path, 'file2.txt'), + ] + main(args) diff --git a/tests/resources/file1.txt b/tests/resources/file1.txt new file mode 100644 index 00000000000..e2129701f1a --- /dev/null +++ b/tests/resources/file1.txt @@ -0,0 +1 @@ +file1 diff --git a/tests/resources/file2.txt b/tests/resources/file2.txt new file mode 100644 index 00000000000..6c493ff740f --- /dev/null +++ b/tests/resources/file2.txt @@ -0,0 +1 @@ +file2 diff --git a/tox.ini b/tox.ini index be6b9b3ef80..521cba10655 100644 --- a/tox.ini +++ b/tox.ini @@ -14,10 +14,10 @@ deps = coverage nose-exclude coverargs = - --with-coverage - --cover-tests - --cover-branches - --cover-inclusive + --with-coverage + --cover-tests + --cover-branches + --cover-inclusive [testenv:gae] deps = @@ -49,11 +49,7 @@ deps = gcloud commands = nosetests \ - --exclude-dir=bigquery/tests/appengine \ - --exclude-dir=bigquery/samples/appengine_auth \ --exclude-dir=appengine \ - --exclude-dir=datastore/ndb \ - --exclude-dir=localtesting \ {[testenv]coverargs} \ {posargs}