Skip to content

How can we cover unit testing for datastore? #2

Closed

Description

@jgeewax

Right now, the only way to develop this is by hitting the live Cloud Datastore API. Is there a way we can use these API calls in unit tests without mocking?

Can we have a "local datastore" server that understands the API and makes it easy for local development?

Activity

  1. proppy commented on Jan 29, 2014

    @proppy
    Contributor

    You could use gcd: the local development server, see:
    https://developers.google.com/datastore/docs/tools/devserver

  2. jgeewax commented on Jan 30, 2014

    @jgeewax
    ContributorAuthor

    That looks good for local development. It runs on Java right ?

    I wonder how difficult it would be to patch in the stubs from AppEngine's dev_appserver.py so that i can use something akin to ext.testbed to unittest locally (ie, without hitting the wire, stay all in Python).

  3. proppy commented on Jan 30, 2014

    @proppy
    Contributor

    That looks good for local development. It runs on Java right ?

    Yes, it is embedding the App Engine Java development server and running the same servlet that is running in production.

    I wonder how difficult it would be to patch in the stubs from AppEngine's dev_appserver.py so that i can use something akin to ext.testbed to unittest locally (ie, without hitting the wire, stay all in Python).

    You would have to handle the datastore_v1.proto to datastore_v4 convertion somehow.

    Keep in mind that datastore_v4 private interface is not really documented and also subject to change: datastore_v1 is the public versionned interface.

  4. jgeewax commented on Jan 30, 2014

    @jgeewax
    ContributorAuthor

    Yikes. Well I realllly don't want to force people to spin up a local server in order to run unit tests...

    We'll have to come up with a way to stub this out.

  5. tseaver commented on Sep 23, 2014

    @tseaver
    Contributor

    #130 adds 100% unit test coverage for modules in gcloud, gcloud.datastore. I would call its strategy "stubbing" (testcases explicitly stub out the http or connection objects) rather than "mocking" (using a general-purpose utilitiy like 'mock').

  6. tseaver commented on Oct 17, 2014

    @tseaver
    Contributor

    #106 exists to cover the deficiencies of testing with stubbed / mocked backends.

  7. modified the milestone: on Jan 30, 2015
  8. added a commit that references this issue on Jul 12, 2017
  9. 83 remaining items

  10. added 6 commits that reference this issue on Nov 24, 2025
    7ae7c34
    5d3931f
    7cdc1f2
    36520a2
    75815a6
    0518be5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.testingtype: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions