Functional test - Add datastore query tests

This implements `projection`, `offset` and `group_by` on `datastore.query.Query`. I looked and didn't see any equivalent bugs from them.

As new `Query` features are outside the scope of functional / regression testing, I am going to peel them off into a separate PR and then rebase this one onto it after that is reviewed. However, please feel free to dig into this review.

Some other things to notice:
- #280 was filed as a result of this. 
- In `gcloud-node`, fetching on a query returns a new query with the cursor set. We set the cursor after a query is completed, but this is not `start_cursor` so a user is still required to create a new cursor via:

   ```python
   results = query.fetch()
   new_query = query.with_cursor(query.cursor())
   ```

  Also note that in tests like `test_limit_queries` #280 is most relevant and the `gcloud-node` implementation could also benefit from the `more_results` boolean returned from a connection.
- Raising a `RuntimeError` on `cursor()` access feels wrong. In reality, we'd like to access the start cursor and the end cursor and the one set on `Query` is one we next really want set, but instead returned as part of `fetch` results.
- Running these tests very often (i.e. 3 times a minute) resulted in very flaky results for the filter tests. I tried to address this by doing bulk adds / deletes in a `transaction` but it still was flaky.  /cc @pcostell
- The `gcloud-node` implementation seems to allow `Dataset.save` to take a list of entities and save them in a transaction. This may be worth adding.
- We haven't implemented [`keys_only` queries][1] though I'm unsure if the Cloud Datastore API supports this.
- Getting just the `dict` from two `Entity`s for comparison should be easier. I suppose we could implement `__eq__` here.
- The code in `test_query_paginate_with_offset` is much more convoluted than the `gcloud-node` [equivalent][2]. This is mostly because `runQuery` does a lot under the covers in node land.
- I am unclear why the `group_by` query only returns two entities. Maybe someone can fill me in?

[1]: https://cloud.google.com/appengine/docs/python/datastore/queries#Python_Keys_only_queries
[2]: https://github.com/GoogleCloudPlatform/gcloud-node/blob/029f3a52e05a3b59bd07f69d7d2032b7a61fe331/regression/datastore.js#L312
Does it make sense to build the docs in `script` instead of `update_docs`?
We are calling regression there (on non-PRs) but not making the docs.

On Mon, Oct 27, 2014 at 3:20 PM, Silvano Luciani <notifications@github.com>
wrote:

> In tox.ini:
>
> > @@ -33,7 +33,8 @@ deps =
> >  basepython =
> >      python2.7
> >  commands =
> > -    python -c "import shutil; shutil.rmtree('docs/_build')"
> > +    python -c "import os, shutil; shutil.rmtree('docs/_build') " \
> > +              "if os.path.exists('docs/_build') else None"
>
> re after_success: yeah, everything that happens in that step happens
> after the build is considered successful, so it doesn't influence the
> status of the build. I fixed it in gcloud-node
> <https://github.com/GoogleCloudPlatform/gcloud-python/pull/281/files#r19441686>
> recently, when I was working on fixing the flaky tests for datastore.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/gcloud-python/pull/281/files#r19441946>
> .
>



-- 
Danny Hermes
(815) 440-7093