8000 chore: unit test coverage and additional refactoring for `spanner_dbapi` by mf2199 · Pull Request #532 · googleapis/python-spanner-django · GitHub
[go: up one dir, main page]

Skip to content

chore: unit test coverage and additional refactoring for spanner_dbapi #532

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

Merged
merged 40 commits into from
Oct 26, 2020

Conversation

mf2199
Copy link
Contributor
@mf2199 mf2199 commented Oct 6, 2020

Listed below is the summary of the proposed changes.

1. Refactoring the contents of spanner_dbapi package:

  • imports re-formatted for consistency with the Spanner common scheme;
  • the ColumnInfo class and few static methods not listed in PEP-249 moved from cursor.py into a new _helpers.py file;
  • scripting method connect moved from __init__.py into connection.py;
  • docstrings in connection.py and cursor.py partially revised and updated;
  • the order of methods in the ConnectionandCursor` classes was updated to follow that of PEP-249 definitions;
  • fixed potential bug inside parse_utils.parse_insert() method (the old code left commented-out for now);
  • slight renaming and punctuation fixes in parser.py;
  • optimized version.py definitions;

2. Improving the unit test coverage level up to 100%:

  • several new unit tests added to cover the existing gaps in spanner_dbapi;
  • django_spanner was temporarily excluded from the coverage since it's covered by Django system tests anyway;
  • the minimum coverage fail threshold increased from 0% to 90%, to be set even higher in the future updates;
  • the tests/spanner_dbapi folder refactored into tests/unit/spanner_dbapi as to follow Spanner's common folder structure;
  • tox.ini file removed as deprecated since the switch to the Nox framework.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 6, 2020
@mf2199 mf2199 changed the title chore: refactoring of cursor.py chore: refactoring and unit test coverage for spanner_dbapi Oct 11, 2020
@mf2199 mf2199 added api: spanner Issues related to the googleapis/python-spanner-django API. type: process A process-related concern. May include testing, release, or the like. labels Oct 11, 2020
@mf2199 mf2199 requested a review from IlyaFaer October 11, 2020 17:36
@mf2199 mf2199 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 11, 2020
@mf2199 mf2199 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 14, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 14, 2020
@mf2199 mf2199 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 20, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 20, 2020
Copy link
Contributor
@c24t c24t left a comment

Choose a reason for hiding this comment

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

All the changes here look sound individually, but putting them in one big PR like this does make it hard to review (and may cause painful merge conflicts for other branches in flight since this will be squashed into a single commit on master). It's possible that I missed something, but LGTM otherwise.

)
from .version import google_client_info
from google.cloud.spanner_dbapi.connection import Connection
from google.cloud.spanner_dbapi.connection import connect
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW our current isort config will mangle this formatting. Did you do this by hand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I did. It would work either way, and was more of the matter of a consistent visual appearance.

Comment on lines +57 to +58
# TODO: File a bug with Cloud Spanner and the Python client maintainers
# about a lost commit when res isn't read from.
Copy link
Contributor

Choose a reason for hiding this comment

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

I know your change just moved this comment, but I wonder what the story is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be a good question for the original code developer who unfortunately is no longer a member of our team. I'm not even sure what's the purpose of res, as the function does not return anything. We should probably revise this method later.

Comment on lines +265 to +270

# pyformat_str_count = after_values_sql.count("%s")
# if pyformat_str_count > 0:
# raise ProgrammingError(
# 'no params yet there are %d "%%s" tokens' % pyformat_str_count
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# pyformat_str_count = after_values_sql.count("%s")
# if pyformat_str_count > 0:
# raise ProgrammingError(
# 'no params yet there are %d "%%s" tokens' % pyformat_str_count
# )

LGTM, no reason to keep the old code around as far as I can tell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has already been addressed in a separate PR - precisely for the reason mentioned earlier, that is not to make this already large PR even bigger.

Comment on lines +317 to +324
# def test_handle_insert(self):
# pass
#
# def test_do_execute_insert_heterogenous(self):
# pass
#
# def test_do_execute_insert_homogenous(self):
# pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like these are new tests, why add them as commented stubs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has also been addressed in a separate PR.

@mf2199 mf2199 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 22, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 24, 2020
Copy link
Contributor
@olavloite olavloite left a comment

Choose a reason for hiding this comment

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

This looks generally good to me, with a couple of small questions/suggestions regarding the docs. I'll leave the official approval to @c24t.

@mf2199
Copy link
Contributor Author
mf2199 commented Oct 25, 2020

@olavloite Thanks for the review. Made all the changes as suggested. PTAL.

@c24t c24t merged commit 927e178 into googleapis:master Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner-django API. cla: yes This human has signed the Contributor License Agreement. type: process A process-related concern. May include testing, release, or the like.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0