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

test: fix flaky system test #701

Merged
merged 3 commits into from
Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/system/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import datetime
import functools
import operator
import uuid

import pytest
import pytz
Expand Down Expand Up @@ -373,10 +374,12 @@ def test_query_default_namespace_when_context_namespace_is_other(

https://github.com/googleapis/python-ndb/issues/476
"""
unique_id = str(uuid.uuid4())

class SomeKind(ndb.Model):
foo = ndb.IntegerProperty()
bar = ndb.StringProperty()
discriminator = ndb.StringProperty(default=unique_id)

entity1 = SomeKind(foo=1, bar="a", id="x", namespace=other_namespace)
entity1.put()
Expand All @@ -389,7 +392,7 @@ class SomeKind(ndb.Model):
eventually(SomeKind.query(namespace=other_namespace).fetch, length_equals(1))

with client_context.new(namespace=other_namespace).use():
query = SomeKind.query(namespace="")
query = SomeKind.query(namespace="").filter(SomeKind.discriminator == unique_id)
results = eventually(query.fetch, length_equals(1))

assert results[0].foo == 2
Expand Down