Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System test failure with Datastore emulator #118

Closed
chrisrossi opened this issue Jun 24, 2019 · 1 comment · Fixed by #119
Closed

System test failure with Datastore emulator #118

chrisrossi opened this issue Jun 24, 2019 · 1 comment · Fixed by #119
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@chrisrossi
Copy link
Contributor

The test, tests.system.test_query:test_fetch_page fails when run against the Datastore emulator:

_________________________________________________ test_fetch_page _________________________________________________

dispose_of = <function dispose_of.<locals>.delete_entity at 0x7f4cf9932950>

    @pytest.mark.usefixtures("client_context")
    def test_fetch_page(dispose_of):
        page_size = 5
        n_entities = page_size * 2
    
        class SomeKind(ndb.Model):
            foo = ndb.IntegerProperty()
    
        @ndb.tasklet
        def make_entities():
            entities = [SomeKind(foo=i) for i in range(n_entities)]
            keys = yield [entity.put_async() for entity in entities]
            return keys
    
        for key in make_entities().result():
            dispose_of(key._key)
    
        query = SomeKind.query().order(SomeKind.foo)
        eventually(query.fetch, _length_equals(n_entities))
    
        results, cursor, more = query.fetch_page(page_size)
        assert [entity.foo for entity in results] == [0, 1, 2, 3, 4]
        assert more
    
        safe_cursor = cursor.urlsafe()
        next_cursor = ndb.Cursor(urlsafe=safe_cursor)
        results, cursor, more = query.fetch_page(
            page_size, start_cursor=next_cursor
        )
        assert [entity.foo for entity in results] == [5, 6, 7, 8, 9]
>       assert not more
E       assert not True

tests/system/test_query.py:525: AssertionError
@chrisrossi chrisrossi self-assigned this Jun 24, 2019
@chrisrossi chrisrossi added the 🚨 This issue needs some love. label Jun 24, 2019
@chrisrossi
Copy link
Contributor Author

This is caused by:

googleapis/google-cloud-datastore#130

chrisrossi pushed a commit to chrisrossi/python-ndb that referenced this issue Jun 24, 2019
Improve usage of Datastore Emulator by not requiring credentials to be
set.

Rewrite failing system test to work around emulator discrepency with
``more_results`` field of ``QueryResultsBatch`` message.

See: googleapis/google-cloud-datastore#130

Update the ``more`` return value of ``Query.fetch_page`` to be ``False``
if an empty page has just been retrieved. This is intended to prevent
possible infinite loops in client code when using the Datastore
emulator.
chrisrossi pushed a commit that referenced this issue Jun 24, 2019
Improve usage of Datastore Emulator by not requiring credentials to be
set.

Rewrite failing system test to work around emulator discrepency with
``more_results`` field of ``QueryResultsBatch`` message.

See: googleapis/google-cloud-datastore#130

Update the ``more`` return value of ``Query.fetch_page`` to be ``False``
if an empty page has just been retrieved. This is intended to prevent
possible infinite loops in client code when using the Datastore
emulator.
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. labels Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants