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

tests: refactor systests to use pytest fixtures / idioms #210

Merged
merged 13 commits into from Aug 19, 2021

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented Aug 9, 2021

Closes #208.

…dule

Use pytest fixtures / idioms, rather than legacy setup / teardown.

Toward #208.
Use pytest fixtures / idioms.

Toward #208.
Remaining 'Config.CLIENT' and 'Config.TO_DELETE' left for consumption by
doctests.
We aren't running the doctests any longer, and we should be using
pytest-doctest integration to leverage the systest fixtures.
@tseaver tseaver requested review from chrisrossi, crwilcox and a team August 9, 2021 22:00
@tseaver tseaver requested a review from a team as a code owner August 9, 2021 22:00
@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-datastore API. label Aug 9, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 9, 2021
@tseaver tseaver changed the title refactor: make systests use pytest fixtures / idioms tests: refactor systests to use pytest fixtures / idioms Aug 11, 2021

query = client.query(kind='_Doctest')
cursor = None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: I've ripped out the bit-rotted doctest setup / teardown code here and below (we haven't had a doctests session since googleapis/google-cloud-python#6642, 2018-11-28). #209 tracks the need to get the docstring doctests either tested, or else replaced by snippets / samples.

Copy link
Contributor

@chrisrossi chrisrossi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A few minor nits/questions, but nothing alarming.

tests/system/_helpers.py Outdated Show resolved Hide resolved
tests/system/_helpers.py Outdated Show resolved Hide resolved

# Smoke test to make sure it doesn't blow up. No return value or
# verifiable side effect to verify.
datastore_client.reserve_ids_sequential(key, num_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you call allocate_ids and confirm none of the returned ids are in the reserved space?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, that was your comment ("no verifiable side effects") from #76.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. De memory, she is not so good...

tests/system/_helpers.py Outdated Show resolved Hide resolved
tests/system/_helpers.py Outdated Show resolved Hide resolved

@pytest.fixture(scope="session")
def in_emulator():
return _helpers.get_emulator_dataset() is not None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 57816be

def datastore_client(test_namespace):
emulator_dataset = _helpers.get_emulator_dataset()

if emulator_dataset is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 57816be


# Smoke test to make sure it doesn't blow up. No return value or
# verifiable side effect to verify.
datastore_client.reserve_ids_sequential(key, num_ids)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, that was your comment ("no verifiable side effects") from #76.

@tseaver tseaver merged commit 671dc4b into master Aug 19, 2021
@tseaver tseaver deleted the 208-refactor-systest-using-pytest branch August 19, 2021 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-datastore API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor systests to use pytest fixtures / idioms; split into modules as needed.
2 participants