-
Notifications
You must be signed in to change notification settings - Fork 31
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
Conversation
# Conflicts: # google/cloud/spanner_dbapi/__init__.py # google/cloud/spanner_dbapi/connection.py # tests/spanner_dbapi/test_connection.py
cursor.py
spanner_dbapi
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
# TODO: File a bug with Cloud Spanner and the Python client maintainers | ||
# about a lost commit when res isn't read from. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
||
# 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 | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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.
There was a problem hiding this comment.
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.
# def test_handle_insert(self): | ||
# pass | ||
# | ||
# def test_do_execute_insert_heterogenous(self): | ||
# pass | ||
# | ||
# def test_do_execute_insert_homogenous(self): | ||
# pass |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…on-spanner-django into q-logic-refactor-cursor-alt # Conflicts: # google/cloud/spanner_dbapi/__init__.py # google/cloud/spanner_dbapi/connection.py # google/cloud/spanner_dbapi/cursor.py # tests/spanner_dbapi/test_connect.py # tests/spanner_dbapi/test_connection.py
Q logic refactor cursor alt
There was a problem hiding this 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.
@olavloite Thanks for the review. Made all the changes as suggested. PTAL. |
Listed below is the summary of the proposed changes.
1. Refactoring the contents of
spanner_dbapi
package:ColumnInfo
class and few static methods not listed in PEP-249 moved fromcursor.py
into a new_helpers.py
file;connect
moved from__init__.py
intoconnection.py
;connection.py
andcursor.py
partially revised and updated;and
Cursor` classes was updated to follow that of PEP-249 definitions;parse_utils.parse_insert()
method (the old code left commented-out for now);parser.py
;version.py
definitions;2. Improving the unit test coverage level up to 100%:
spanner_dbapi
;django_spanner
was temporarily excluded from the coverage since it's covered by Django system tests anyway;tests/spanner_dbapi
folder refactored intotests/unit/spanner_dbapi
as to follow Spanner's common folder structure;tox.ini
file removed as deprecated since the switch to the Nox framework.