@@ -6,23 +6,23 @@ Contributing
66#. Make sure that your commit messages clearly describe the changes.
77#. Send a pull request.
88
9- Here are some guidelines for hacking on gcloud-python.
9+ Here are some guidelines for hacking on `` gcloud-python `` .
1010
1111Using a Development Checkout
1212----------------------------
1313
14- You'll have to create a development environment to hack on gcloud-python,
14+ You'll have to create a development environment to hack on `` gcloud-python `` ,
1515using a Git checkout:
1616
17- - While logged into your GitHub account, navigate to the gcloud-python repo on
18- GitHub.
17+ - While logged into your GitHub account, navigate to the `` gcloud-python `` repo
18+ on GitHub.
1919
2020 https://github.com/GoogleCloudPlatform/gcloud-python
2121
22- - Fork and clone the gcloud-python repository to your GitHub account by
22+ - Fork and clone the `` gcloud-python `` repository to your GitHub account by
2323 clicking the "Fork" button.
2424
25- - Clone your fork of gcloud-python from your GitHub account to your local
25+ - Clone your fork of `` gcloud-python `` from your GitHub account to your local
2626 computer, substituting your account username and specifying the destination
2727 as "hack-on-gcloud". E.g.::
2828
@@ -39,25 +39,25 @@ using a Git checkout:
3939Now your local repo is set up such that you will push changes to your GitHub
4040repo, from which you can submit a pull request.
4141
42- - Create a virtualenv in which to install gcloud-python::
42+ - Create a virtualenv in which to install `` gcloud-python `` ::
4343
4444 $ cd ~/hack-on-gcloud
45- $ virtualenv -ppython2 .7 env
45+ $ virtualenv --python python2 .7 env
4646
4747 Note that very old versions of virtualenv (virtualenv versions below, say,
4848 1.10 or thereabouts) require you to pass a ``--no-site-packages`` flag to
4949 get a completely isolated environment.
5050
51- You can choose which Python version you want to use by passing a ``-p ``
52- flag to ``virtualenv``. For example, ``virtualenv -ppython2 .7``
51+ You can choose which Python version you want to use by passing a ``--python ``
52+ flag to ``virtualenv``. For example, ``virtualenv --python python2 .7``
5353 chooses the Python 2.7 interpreter to be installed.
5454
5555 From here on in within these instructions, the ``~/hack-on-gcloud/env``
5656 virtual environment you created above will be referred to as ``$VENV``.
5757 To use the instructions in the steps that follow literally, use the
5858 ``export VENV=~/hack-on-gcloud/env`` command.
5959
60- - Install gcloud-python from the checkout into the virtualenv using
60+ - Install `` gcloud-python `` from the checkout into the virtualenv using
6161 ``setup.py develop ``. Running ``setup.py develop `` *must * be done while
6262 the current working directory is the ``gcloud-python `` checkout directory::
6363
@@ -83,7 +83,7 @@ and then ``pip install`` the dependencies again::
8383Adding Features
8484---------------
8585
86- In order to add a feature to gcloud-python:
86+ In order to add a feature to `` gcloud-python `` :
8787
8888- The feature must be documented in both the API and narrative
8989 documentation (in ``docs/ ``).
@@ -124,18 +124,18 @@ Exceptions to PEP8:
124124Running Tests
125125--------------
126126
127- - To run all tests for gcloud-python on a single Python version, run
127+ - To run all tests for `` gcloud-python `` on a single Python version, run
128128 ``nosetests `` from your development virtualenv (See
129129 *Using a Development Checkout * above).
130130
131- - To run the full set of gcloud-python tests on all platforms, install `` tox ``
132- (https://testrun.org/tox/) into a system Python. The ``tox `` console
131+ - To run the full set of `` gcloud-python `` tests on all platforms, install
132+ `` tox `` (https://testrun.org/tox/) into a system Python. The ``tox `` console
133133 script will be installed into the scripts location for that Python. While
134- ``cd ``'ed to the gcloud-python checkout root directory (it contains `` tox.ini ``),
135- invoke the ``tox `` console script. This will read the `` tox.ini `` file and
136- execute the tests on multiple Python versions and platforms; while it runs,
137- it creates a virtualenv for each version/platform combination. For
138- example::
134+ ``cd ``'ed to the `` gcloud-python `` checkout root directory (it contains
135+ `` tox.ini ``), invoke the ``tox `` console script. This will read the
136+ `` tox.ini `` file and execute the tests on multiple Python versions and
137+ platforms; while it runs, it creates a virtualenv for each version/platform
138+ combination. For example::
139139
140140 $ sudo /usr/bin/pip install tox
141141 $ cd ~/hack-on-gcloud/
@@ -211,6 +211,36 @@ Running System Tests
211211
212212 $ python system_tests/clear_datastore.py
213213
214+ - System tests can also be run against local `emulators `_ that mock
215+ the production services. For example, to run the system tests
216+ with the ``datastore `` emulator, first start the emulator and
217+ take note of the process ID::
218+
219+ $ gcloud beta emulators datastore start &
220+ [1] 33333
221+
222+ then determine the environment variables needed to interact with
223+ the emulator::
224+
225+ $ gcloud beta emulators datastore env-init
226+ export DATASTORE_LOCAL_HOST=localhost:8417
227+ export DATASTORE_HOST=http://localhost:8417
228+ export DATASTORE_DATASET=gcloud-settings-app-id
229+ export DATASTORE_PROJECT_ID=gcloud-settings-app-id
230+
231+ using these environment variables run the emulator::
232+
233+ $ DATASTORE_HOST=http://localhost:8471 \
234+ > DATASTORE_DATASET=gcloud-settings-app-id \
235+ > GCLOUD_NO_PRINT=true \
236+ > python system_tests/run_system_test.py --package=datastore
237+
238+ and after completion stop the emulator::
239+
240+ $ kill 33333
241+
242+ .. _emulators : https://cloud.google.com/sdk/gcloud/reference/beta/emulators/
243+
214244Test Coverage
215245-------------
216246
@@ -230,22 +260,22 @@ changed to reflect the bug fix, ideally in the same commit that fixes the bug
230260or adds the feature.
231261
232262To build and review docs (where ``$VENV `` refers to the virtualenv you're
233- using to develop gcloud-python):
263+ using to develop `` gcloud-python `` ):
234264
2352651. After following the steps above in "Using a Development Checkout", install
236266 Sphinx and all development requirements in your virtualenv::
237267
238268 $ cd ~/hack-on-gcloud
239269 $ $VENV/bin/pip install Sphinx
240270
241- 2. Change into the ``docs `` directory within your gcloud-python checkout and
271+ 2. Change into the ``docs `` directory within your `` gcloud-python `` checkout and
242272 execute the ``make `` command with some flags::
243273
244274 $ cd ~/hack-on-gcloud/gcloud-python/docs
245275 $ make clean html SPHINXBUILD=$VENV/bin/sphinx-build
246276
247277 The ``SPHINXBUILD=... `` argument tells Sphinx to use the virtualenv Python,
248- which will have both Sphinx and gcloud-python (for API documentation
278+ which will have both Sphinx and `` gcloud-python `` (for API documentation
249279 generation) installed.
250280
2512813. Open the ``docs/_build/html/index.html `` file to see the resulting HTML
0 commit comments