GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gigantic re-organization of tests. · michaelMath/python-docs-samples@a1ad83b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .coveragerc
  • .gitignore
  • .travis.yml
  • CONTRIBUTING.md
  • TESTING.md
  • appengine
    • app_identity/signing
      • main_test.py
    • bigquery
      • main_test.py
      • resources
        • datasets-list.json
    • blobstore
      • main_test.py
    • cloudsql
      • main_test.py
    • images
      • main_test.py
    • localtesting
      • resources
        • queue.yaml
      • test_task_queue.py
    • logging
      • reading_logs
        • main_test.py
      • writing_logs
        • main_test.py
    • mailgun
      • main_test.py
    • memcache/guestbook
      • main_test.py
    • multitenancy
      • datastore_test.py
      • memcache_test.py
      • taskqueue_test.py
    • ndb
      • modeling
        • contact_with_group_models_test.py
        • keyproperty_models_test.py
        • naive_models_test.py
        • parent_child_models_test.py
        • relation_model_models_test.py
        • structured_property_models_test.py
      • overview
        • main_test.py
      • transactions
        • main_test.py
    • resources
      • app.yaml
    • storage
      • main_test.py
  • bigquery/api
    • async_query_test.py
    • export_data_to_cloud_storage_test.py
    • getting_started_test.py
    • list_datasets_projects_test.py
    • load_data_by_post_test.py
    • load_data_from_csv_test.py
    • resources
      • data.csv
      • data.json
      • schema.json
      • streamrows.json
    • streaming_test.py
    • sync_query_test.py
  • blog/introduction_to_data_models_in_cloud_datastore
    • blog_test.py
    • wiki_test.py
  • cloud_logging/api
    • list_logs_test.py
  • compute/api
    • create_instance_test.py
  • datastore/api
    • snippets_test.py
    • tasks_test.py
  • lib
    • README.md
  • managed_vms
    • __init__.py
    • analytics
      • __init__.py
    • cloudsql
      • __init__.py
      • main_test.py
    • datastore
      • README.md
      • __init__.py
      • app.yaml
      • main.py
      • main_test.py
    • disk
      • __init__.py
      • main.py
      • main_test.py
    • extending_runtime
      • __init__.py
      • main_test.py
    • hello_world_compat
      • __init__.py
      • main_test.py
    • hello_world
      • __init__.py
      • main_test.py
    • mailgun
      • __init__.py
    • memcache
      • __init__.py
      • main_test.py
    • pubsub
      • __init__.py
      • main_test.py
    • sendgrid
      • __init__.py
    • static_files
      • __init__.py
      • main_test.py
    • storage
      • README.md
      • __init__.py
      • app.yaml
      • main.py
      • main_test.py
    • tests
      • disk_test.py
      • runserver.py
    • twilio
      • __init__.py
    • websockets
      • __init__.py
      • app.yaml
  • monitoring/api
    • auth_test.py
  • python-docs-samples.json.enc
  • requirements-py27-dev.txt
  • requirements-py34-dev.txt
  • scripts
    • check_requirements.py
    • encrypt-secrets.sh
    • prepare-testing-project.sh
    • resources
      • docs-links.json
    • update_requirements.py
  • secrets.tar.enc
  • storage/api
    • compose_objects_test.py
    • list_objects_test.py
    • resources
      • file1.txt
      • file2.txt
  • testing
    • __init__.py
    • appengine.py
    • cloud.py
    • flaky.py
    • resources
      • test-env.tmpl.sh
    • utils.py
  • tests/scripts
    • fetch_gae_sdk.py
    • travis-before-install.sh
  • tox.ini

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.coveragerc‎

Copy file name to clipboardExpand all lines: .coveragerc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include =
88
monitoring/*
99
storage/*
1010
cloud_logging/*
11+
managed_vms/*
1112
[report]
1213
exclude_lines =
1314
pragma: NO COVER
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ coverage-gae.json
55
.tox
66
coverage.xml
77
nosetests.xml
8+
nosetests-*.xml
89
python-docs-samples.json
10+
service-account.json
911
__pycache__
1012
*db\.sqlite3
1113
managed_vms/django_tutorial/static/*
1214
**/migrations/*
15+
lib
16+
testing/resources/test-env.sh
17+
testing/resources/service-account.json
18+
secrets.tar
Collapse file

‎.travis.yml‎

Copy file name to clipboard
+11-19Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
sudo: false
2-
#add language, etc. here
32
language: python
4-
3+
services:
4+
- memcached
5+
- mysql
56
branches:
67
only:
7-
- master
8-
8+
- master
99
cache:
1010
directories:
1111
- $HOME/.cache
12-
1312
env:
1413
global:
1514
- PATH=${PATH}:${HOME}/gcloud/google-cloud-sdk/bin
16-
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/python-docs-samples.json
15+
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/resources/service-account.json
1716
- GAE_PYTHONPATH=${HOME}/.cache/google_appengine
18-
- TEST_BUCKET_NAME=bigquery-devrel-samples-bucket
19-
- TEST_PROJECT_ID=bigquery-devrel-samples
20-
17+
- secure: YIowCOMJ97rTcehKVT6Gi3u0Etm8s9+TBRGsNPJLgSF2zZdsh9IHcIc+tMDUMR3lpOe8y2a060RuODQcRsW1W1LIHej+ZE/gv6vATT6qNA3eKfKmZ9AyrpBO0fTOHlHrGBuU9ktBPR+iqvnq8MLWjnUozPFMJbuNBFITU7JP8jc=
2118
before_install:
22-
- tests/scripts/travis-before-install.sh
23-
19+
- openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d
20+
- tar xvf secrets.tar
2421
install:
25-
# TODO: unpin tox when the following issue is fixed
26-
# https://bitbucket.org/hpk42/tox/issues/285/tox-220-breaks-some-toxini-config-files
2722
- pip install tox
28-
23+
- pip install -e git+https://github.com/GoogleCloudPlatform/python-repo-tools#egg=python-repo-tools
24+
- gcp-python-repo-tools download-appengine-sdk `dirname "${GAE_PYTHONPATH}"`
2925
script:
26+
- source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh
3027
- tox
31-
32-
# Coveralls is disabled in travis because travis does not run all of our
33-
# tests. The full suite of tests is run on an internal Jenkins instance.
34-
# after_success:
35-
# - coveralls
Collapse file

‎CONTRIBUTING.md‎

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-99Lines changed: 1 addition & 99 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -36,102 +36,4 @@ be able to accept your pull requests.
3636

3737
## Testing
3838

39-
The tests in this repository run against live services, therefore, it
40-
takes a bit of configuration to run all of the tests locally.
41-
42-
### Local setup
43-
44-
Before you can run tests locally you must have:
45-
46-
* The latest [tox](https://tox.readthedocs.org/en/latest/) and
47-
[pip](https://pypi.python.org/pypi/pip) installed.
48-
49-
$ sudo pip install --upgrade tox pip
50-
51-
* The [Google Cloud SDK](https://cloud.google.com/sdk/) installed. You
52-
can do so with the following command:
53-
54-
$ curl https://sdk.cloud.google.com | bash
55-
56-
* Most tests require you to have an active, billing-enabled project on
57-
the
58-
[Google Developers Console](https://console.developers.google.com).
59-
60-
* You will need a set of
61-
[Service Account Credentials](https://console.developers.google.com/project/_/apiui/credential)
62-
for your project in ``json`` form.
63-
64-
* Set the environment variables appropriately for your project.
65-
66-
$ export GOOGLE_APPLICATION_CREDENTIALS=your-service-account-json-file
67-
$ export TEST_PROJECT_ID=your-project-id
68-
$ export TEST_BUCKET_NAME=your-bucket-name
69-
70-
If you want to run the Google App Engine tests, you will need:
71-
72-
* The App Engine Python SDK. You can install this by downloading it [here]
73-
(https://cloud.google.com/appengine/downloads?hl=en)
74-
75-
* You can also download it programatically with the
76-
tests/scripts/fetch_gae_sdk.py
77-
78-
$ test/scripts/fetch_gae_sdk.py <dest dir>
79-
80-
* You will need to set an additional environment variable:
81-
82-
$ export GAE_PYTHONPATH=<path your AppeEngine sdk>
83-
84-
To run the bigquery tests:
85-
86-
* Create a dataset in your project named `test_dataset`.
87-
88-
gcloud alpha bigquery datasets create test_dataset
89-
90-
* Load sample data into google cloud storage (for import tests):
91-
92-
gsutil cp tests/resources/data.csv gs://$TEST_BUCKET_NAME/data.csv
93-
94-
* Load the sample data into a table named `test_table` (for export and streaming tests):
95-
96-
gcloud alpha bigquery import \
97-
gs://$TEST_BUCKET_NAME/data.csv \
98-
test_dataset/test_table \
99-
--schema-file tests/resources/schema.json
100-
101-
### Test environments
102-
103-
We use [tox](https://tox.readthedocs.org/en/latest/) to configure
104-
multiple python environments:
105-
106-
* ``py27`` contains tests for samples that run in a normal Python 2.7
107-
environment. This is (mostly) everything outside of the
108-
``appengine`` directory.
109-
* ``gae`` contains tests for samples that run only in Google App
110-
Engine. This is (mostly) everything in the ``appengine`` directory.
111-
* ``pep8`` just runs the linter.
112-
113-
To run tests for a particular environment, invoke tox with the ``-e``
114-
flag:
115-
116-
tox -e py27
117-
118-
To run one particular test suite or provide additional parameters to
119-
``nose``, invoke tox like this:
120-
121-
toxe -e py27 -- storage/tests/test_list_objects.py
122-
123-
*Note*: The ``gae`` environment can't be told to run one particular
124-
test at this time.
125-
126-
### Adding new tests
127-
128-
There are a handful of common testing utilities are located under
129-
``tests``, see existing tests for example usage.
130-
131-
When adding a new top-level directory, be sure to edit ``.coveragerc``
132-
to include it in coveralls.
133-
134-
To add new tests that require Google App Engine, please place them in
135-
the ``appengine`` directory if possible. If you place them elsewhere,
136-
you will need to modify ``tox.ini`` to make the environments
137-
appropriately run or ignore your test.
39+
See [TESTING.md](TESTING.md).
Collapse file

‎TESTING.md‎

Copy file name to clipboard
+79Lines changed: 79 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Testing
2+
3+
The tests in this repository are system tests and run against live services, therefore, it takes a bit of configuration to run all of the tests locally.
4+
5+
Before you can run tests locally you must have:
6+
7+
* The latest [tox](https://tox.readthedocs.org/en/latest/),
8+
[pip](https://pypi.python.org/pypi/pip), and [gcp-python-repo-tools](https://pypi.python.org/pypi/gcp-python-repo-tools) installed.
9+
10+
$ sudo pip install --upgrade tox pip gcp-python-repo-tools
11+
12+
* The [Google Cloud SDK](https://cloud.google.com/sdk/) installed. You
13+
can do so with the following command:
14+
15+
$ curl https://sdk.cloud.google.com | bash
16+
17+
## Preparing a project for testing
18+
19+
Most tests require you to have an active, billing-enabled project on the
20+
[Google Cloud Console](https://console.cloud.google.com).
21+
22+
### Creating resources
23+
24+
Some resources need to be created in a project ahead of time before testing. We have a script that can create everything needed:
25+
26+
gcloud config set project <your-project-id>
27+
scripts/prepare-testing-project.sh
28+
29+
The script will also instruct you to follow a URL to enable APIs. You will need to do that.
30+
31+
### Getting a service account key
32+
33+
From the Cloud Console, create a new Service Account and download its json key. Place this file in `testing/resources/service-account.json`.
34+
35+
## Environment variables
36+
37+
* Copy `testing/resources/test-env.tmpl.sh` to `testing/resources/test-env.sh`, and updated it with your configuration.
38+
* Run `source testing/resources/test-env.sh`.
39+
* Run `export GOOGLE_APPLICATION_CREDENTIALS=testing/resources/service-account.json`.
40+
41+
If you want to run the Google App Engine tests, you will need:
42+
43+
* The App Engine Python SDK. You can also download it programatically with `gcp-python-repo-tools`:
44+
45+
$ gcp-python-repo-tools download-appengine-sdk <dest>
46+
47+
* Set the `GAE_PYTHONPATH` variable:
48+
49+
$ export GAE_PYTHONPATH=<path your AppeEngine sdk>
50+
51+
### Test environments
52+
53+
We use [tox](https://tox.readthedocs.org/en/latest/) to configure
54+
multiple python environments:
55+
56+
* ``py27`` and ``py34`` contains tests for samples that run in a normal Python 2.7 pr 3.4 environment. This is everything outside of the ``appengine`` directory that isn't slow or flaky.
57+
* ``py27-all`` and ``py34-all`` runs all tests except for App Engine tests. This can time some time and some tests are flaky.
58+
* ``gae`` contains tests for samples that run only in Google App Engine. This is (mostly) everything in the ``appengine`` directory.
59+
* ``pep8`` just runs the linter.
60+
61+
To run tests for a particular environment, invoke tox with the ``-e``
62+
flag:
63+
64+
tox -e py27
65+
66+
To run one particular test suite or provide additional parameters to
67+
``nose``, invoke tox like this:
68+
69+
toxe -e py27 -- storage/tests/test_list_objects.py
70+
71+
### Adding new tests
72+
73+
When adding a new top-level directory, be sure to edit ``.coveragerc``
74+
to include it in coveralls.
75+
76+
To add new tests that require Google App Engine, please place them in
77+
the ``appengine`` directory if possible. If you place them elsewhere,
78+
you will need to modify ``tox.ini`` to make the environments
79+
appropriately run or ignore your test.
Collapse file

‎appengine/app_identity/signing/main_test.py‎

Copy file name to clipboardExpand all lines: appengine/app_identity/signing/main_test.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from tests import AppEngineTestbedCase
15+
from testing import AppEngineTest
1616
import webtest
1717

1818
from . import main
1919

2020

21-
class TestAppIdentityHandler(AppEngineTestbedCase):
21+
class TestAppIdentityHandler(AppEngineTest):
2222
def setUp(self):
2323
super(TestAppIdentityHandler, self).setUp()
2424

Collapse file

‎appengine/bigquery/main_test.py‎

Copy file name to clipboardExpand all lines: appengine/bigquery/main_test.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
1615
import re
1716

1817
from apiclient.http import HttpMock
1918
import mock
20-
import tests
19+
import testing
2120
import webtest
2221

2322
from . import main
2423

2524

26-
class TestAuthSample(tests.AppEngineTestbedCase):
25+
class TestAuthSample(testing.AppEngineTest):
2726

2827
def setUp(self):
2928
super(TestAuthSample, self).setUp()
3029
self.app = webtest.TestApp(main.app)
31-
main.PROJECTID = self.project_id
30+
main.PROJECTID = self.config.GCLOUD_PROJECT
3231

3332
def test_anonymous_get(self):
3433
response = self.app.get('/')
@@ -39,7 +38,7 @@ def test_anonymous_get(self):
3938
r'.*accounts.*Login.*')
4039

4140
def test_loggedin_get(self):
42-
self.loginUser()
41+
self.login_user()
4342

4443
response = self.app.get('/')
4544

@@ -49,10 +48,10 @@ def test_loggedin_get(self):
4948

5049
@mock.patch.object(main.decorator, 'has_credentials', return_value=True)
5150
def test_oauthed_get(self, *args):
52-
self.loginUser()
51+
self.login_user()
5352

5453
mock_http = HttpMock(
55-
os.path.join(self.resource_path, 'datasets-list.json'),
54+
self.resource_path('datasets-list.json'),
5655
{'status': '200'})
5756

5857
with mock.patch.object(main.decorator, 'http', return_value=mock_http):
Collapse file

‎tests/resources/datasets-list.json‎ ‎…ne/bigquery/resources/datasets-list.json‎tests/resources/datasets-list.json renamed to appengine/bigquery/resources/datasets-list.json tests/resources/datasets-list.json renamed to appengine/bigquery/resources/datasets-list.json

Copy file name to clipboard
File renamed without changes.
Collapse file

‎appengine/blobstore/main_test.py‎

Copy file name to clipboardExpand all lines: appengine/blobstore/main_test.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import tests
15+
import testing
1616
import webtest
1717

1818
from . import main
1919

2020

21-
class TestBlobstoreSample(tests.AppEngineTestbedCase):
21+
class TestBlobstoreSample(testing.AppEngineTest):
2222

2323
def setUp(self):
2424
super(TestBlobstoreSample, self).setUp()
2525
self.app = webtest.TestApp(main.app)
2626

2727
def test_form(self):
28-
self.loginUser()
28+
self.login_user()
2929
response = self.app.get('/')
3030

3131
self.assertTrue('/_ah/upload' in response)
Collapse file

‎appengine/cloudsql/main_test.py‎

Copy file name to clipboardExpand all lines: appengine/cloudsql/main_test.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
import re
1717
from unittest.case import SkipTest
1818

19-
import tests
19+
import testing
2020
import webtest
2121

2222
from . import main
2323

2424

25-
class TestMySQLSample(tests.AppEngineTestbedCase):
25+
class TestMySQLSample(testing.AppEngineTest):
2626

2727
def setUp(self):
2828
if not os.path.exists('/var/run/mysqld/mysqld.sock'):

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.