Skip to content

Commit 948a66d

Browse files
author
Jonathan Wayne Parrott
committed
Merge pull request #88 from GoogleCloudPlatform/readme-edit
Moved Testing section to CONTRIBUTING.
2 parents e29e360 + 668c0a7 commit 948a66d

File tree

2 files changed

+103
-82
lines changed

2 files changed

+103
-82
lines changed

CONTRIBUTING.md

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
We'd love to accept your sample apps and patches! Before we can take them, we
66
have to jump a couple of legal hurdles.
77

8-
Please fill out either the individual or corporate Contributor License Agreement
9-
(CLA).
8+
Please fill out either the individual or corporate Contributor License
9+
Agreement (CLA).
1010

1111
* If you are an individual writing original source code and you're sure you
1212
own the intellectual property, then you'll need to sign an [individual CLA]
@@ -16,8 +16,8 @@ Please fill out either the individual or corporate Contributor License Agreement
1616
(https://developers.google.com/open-source/cla/corporate).
1717

1818
Follow either of the two links above to access the appropriate CLA and
19-
instructions for how to sign and return it. Once we receive it, we'll be able to
20-
accept your pull requests.
19+
instructions for how to sign and return it. Once we receive it, we'll
20+
be able to accept your pull requests.
2121

2222
## Contributing A Patch
2323

@@ -33,3 +33,100 @@ accept your pull requests.
3333
recommended coding standards for this organization.
3434
1. Ensure that your code has an appropriate set of unit tests which all pass.
3535
1. Submit a pull request.
36+
37+
## Testing
38+
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, you'll need to create a bigquery dataset:
85+
86+
* Create a dataset in your project named `test_dataset`.
87+
* Create a table named `test_table2`, upload ``tests/resources/data.csv`` and give it the following schema:
88+
89+
Name STRING
90+
Age INTEGER
91+
Weight FLOAT
92+
IsMagic BOOLEAN
93+
94+
95+
### Test environments
96+
97+
We use [tox](https://tox.readthedocs.org/en/latest/) to configure
98+
multiple python environments:
99+
100+
* ``py27`` contains tests for samples that run in a normal Python 2.7
101+
environment. This is (mostly) everything outside of the
102+
``appengine`` directory.
103+
* ``gae`` contains tests for samples that run only in Google App
104+
Engine. This is (mostly) everything in the ``appengine`` directory.
105+
* ``pep8`` just runs the linter.
106+
107+
To run tests for a particular environment, invoke tox with the ``-e``
108+
flag:
109+
110+
tox -e py27
111+
112+
To run one particular test suite or provide additional parameters to
113+
``nose``, invoke tox like this:
114+
115+
toxe -e py27 -- storage/tests/test_list_objects.py
116+
117+
*Note*: The ``gae`` environment can't be told to run one particular
118+
test at this time.
119+
120+
## Adding new tests
121+
122+
There are a handful of common testing utilities are located under
123+
``tests``, see existing tests for example usage.
124+
125+
When adding a new top-level directory, be sure to edit ``.coveragerc``
126+
to include it in coveralls.
127+
128+
To add new tests that require Google App Engine, please place them in
129+
the ``appengine`` directory if possible. If you place them elsewhere,
130+
you will need to modify ``tox.ini`` to make the environments
131+
appropriately run or ignore your test.
132+

README.md

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,89 +5,13 @@ This repository holds the samples used in the python documentation on [cloud.goo
55
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/python-docs-samples.svg)](https://travis-ci.org/GoogleCloudPlatform/python-docs-samples)
66
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/python-docs-samples/badge.svg)](https://coveralls.io/r/GoogleCloudPlatform/python-docs-samples)
77

8-
For more detailed introduction to a product, check the README in the corresponding folder.
8+
For more detailed introduction to a product, check the README in the
9+
corresponding folder.
910

1011
## Contributing changes
1112

1213
* See [CONTRIBUTING.md](CONTRIBUTING.md)
1314

14-
## Testing
15-
16-
The tests in this repository run against live services, therefore, it takes a bit
17-
of configuration to run all of the tests locally.
18-
19-
### Local setup
20-
21-
Before you can run tests locally you must have:
22-
23-
* The latest [tox](https://tox.readthedocs.org/en/latest/) and [pip](https://pypi.python.org/pypi/pip) installed.
24-
25-
$ sudo pip install --upgrade tox pip
26-
27-
* The [Google Cloud SDK](https://cloud.google.com/sdk/) installed. You can do so with the following command:
28-
29-
$ curl https://sdk.cloud.google.com | bash
30-
31-
* Most tests require you to have an active, billing-enabled project on the [Google Developers Console](https://console.developers.google.com).
32-
33-
* You will need a set of [Service Account Credentials](https://console.developers.google.com/project/_/apiui/credential) for your project in ``json`` form.
34-
35-
* Set the environment variables appropriately for your project.
36-
37-
$ export GOOGLE_APPLICATION_CREDENTIALS=your-service-account-json-file
38-
$ export TEST_PROJECT_ID=your-project-id
39-
$ export TEST_BUCKET_NAME=your-bucket-name
40-
41-
If you want to run the Google App Engine tests, you will need:
42-
43-
* The App Engine Python SDK. You can install this by downloading it [here]
44-
(https://cloud.google.com/appengine/downloads?hl=en)
45-
46-
* You can also download it programatically with the tests/scripts/fetch_gae_sdk.py
47-
48-
$ test/scripts/fetch_gae_sdk.py <dest dir>
49-
50-
* You will need to set an additional environment variable:
51-
52-
$ export GAE_PYTHONPATH=<path your AppeEngine sdk>
53-
54-
To run the bigquery tests, you'll need to create a bigquery dataset:
55-
56-
* Create a dataset in your project named `test_dataset`.
57-
* Create a table named `test_table2`, upload ``tests/resources/data.csv`` and give it the following schema:
58-
59-
Name STRING
60-
Age INTEGER
61-
Weight FLOAT
62-
IsMagic BOOLEAN
63-
64-
65-
### Test environments
66-
67-
We use [tox](https://tox.readthedocs.org/en/latest/) to configure multiple python environments:
68-
69-
* ``py27`` contains tests for samples that run in a normal Python 2.7 environment. This is (mostly) everything outside of the ``appengine`` directory.
70-
* ``gae`` contains tests for samples that run only in Google App Engine. This is (mostly) everything in the ``appengine`` directory.
71-
* ``pep8`` just runs the linter.
72-
73-
To run tests for a particular environment, invoke tox with the ``-e`` flag:
74-
75-
tox -e py27
76-
77-
To run one particular test suite or provide additional parameters to ``nose``, invoke tox like this:
78-
79-
toxe -e py27 -- storage/tests/test_list_objects.py
80-
81-
*Note*: The ``gae`` environment can't be told to run one particular test at this time.
82-
83-
## Adding new tests
84-
85-
There are a handful of common testing utilities are located under ``tests``, see existing tests for example usage.
86-
87-
When adding a new top-level directory, be sure to edit ``.coveragerc`` to include it in coveralls.
88-
89-
To add new tests that require Google App Engine, please place them in the ``appengine`` directory if possible. If you place them elsewhere, you will need to modify ``tox.ini`` to make the environments appropriately run or ignore your test.
90-
9115
## Licensing
9216

9317
* See [LICENSE](LICENSE)

0 commit comments

Comments
 (0)