GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: unit test coverage and additional refactoring for `spanner_dbapi` by mf2199 · Pull Request #532 · googleapis/python-spanner-django

This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Conversation

@mf2199

@mf2199 mf2199 commented Oct 6, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mf2199
chore: updated docstrings
92cc0b3
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 6, 2020
mf2199 and others added 23 commits October 6, 2020 18:20
@mf2199
Merge branch 'master' into refactor-cursor-alt
c70ee50
@mf2199
chore: methods rearranged
da4eb61
@mf2199
chore:
d27ff71
@mf2199
chore:
eaa024f
@mf2199
fix: lint
3cde688
@mf2199
chore: refactor
75c6f1c
@mf2199
chore: refactor
4383d1c
@mf2199
Merge remote-tracking branch 'upstream/master' into refactor-cursor-alt
f05307d
# Conflicts:
#	google/cloud/spanner_dbapi/__init__.py
#	google/cloud/spanner_dbapi/connection.py
#	tests/spanner_dbapi/test_connection.py
@mf2199
fix: conflicts in connection.py
a5d6d30
@mf2199
test: coverage for connection.py
2693582
@mf2199
test: [WIP] cursor.py coverage
dd38239
@mf2199
Merge branch 'master' into refactor-cursor-alt
03b440e
@mf2199
fix: unittest assertions
4640c46
@mf2199
chore: unit tests refactored
023ea90
@mf2199
chore: unit test refactored
9abee91
@mf2199
fix: missing arg
7dc3875
@mf2199
test: unit test coverage for `cursor.py'
02b3bd4
@mf2199
fix: assertion call
5e0ee36
@mf2199
fix: assertion call
628f04a
@mf2199
test: unit test coverage for parser.py
58c0bb6
@mf2199
fix: lint
301ca84
@mf2199
test: unit test coverage for parse_utils.py
2e5ba9b
@mf2199
test: unit test coverage for _helpers.py
b4fde4b
@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 mentioned this pull request Oct 13, 2020
WIP: DB-API CONNECTION CLASS MaxxleLLC/python-spanner-django#7
Closed
@mf2199
Merge branch 'master' into refactor-cursor-alt
7d8b016
@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
@mf2199 mf2199 mentioned this pull request Oct 20, 2020
docs: missing docstrings for functions & classes MaxxleLLC/python-spanner-django#13
Closed
c24t
c24t approved these changes Oct 21, 2020
View reviewed changes

@c24t c24t left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_dbapi/__init__.py
)
from .version import google_client_info
from google.cloud.spanner_dbapi.connection import Connection
from google.cloud.spanner_dbapi.connection import connect

@c24t c24t Oct 21, 2020

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mf2199 mf2199 Oct 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_dbapi/_helpers.py
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.

@c24t c24t Oct 21, 2020

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mf2199 mf2199 Oct 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_dbapi/parse_utils.py
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
# )

@c24t c24t Oct 21, 2020

Copy link
Copy Markdown
Contributor

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.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mf2199 mf2199 Oct 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/spanner_dbapi/test_cursor.py
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

@c24t c24t Oct 21, 2020

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mf2199 mf2199 Oct 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@c24t
Merge branch 'master' into refactor-cursor-alt
a73e1d7
@mf2199 mf2199 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 22, 2020
mf2199 and others added 12 commits October 23, 2020 21:04
@mf2199
Merge branch 'refactor-cursor-alt' of https://github.com/q-logic/pyth…
9337fd8
…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
@mf2199
test: unit test for Connection.autocommit property setter
b535bf1
@mf2199
test: unit test for Connection._session_checkout
81db6f7
@mf2199
test: unit test for Connection.transaction_checkout
d484496
@mf2199
test: unit test for Connection._release_session
4c0b83c
@mf2199
test: updated unit test for Connection.close
6580e6a
@mf2199
test: updated unit test for Connection.commit
4b7f7d8
@mf2199
test: updated unit test for Connection.rollback
a6fcbdf
@mf2199
test: updated unit tests for Cursor.execute
b38982a
@mf2199
chore: cleanup
594c9bc
@mf2199
chore: cleanup
da15d94
@mf2199
Merge pull request #21 from q-logic/q-logic-refactor-cursor-alt
2a78830
Q logic refactor cursor alt
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 24, 2020
olavloite
olavloite reviewed Oct 25, 2020
View reviewed changes

@olavloite olavloite left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_dbapi/connection.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_dbapi/connection.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_dbapi/connection.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mf2199
fix: implementing suggested changes
41abaeb
@mf2199

mf2199 commented Oct 25, 2020

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olavloite
olavloite approved these changes Oct 25, 2020
View reviewed changes
c24t
c24t approved these changes Oct 26, 2020
View reviewed changes
@c24t
c24t merged commit 927e178 into googleapis:master Oct 26, 2020
@IlyaFaer IlyaFaer mentioned this pull request Oct 27, 2020
feat: support aborted transactions internal retry #544
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

3 more reviewers
@IlyaFaer IlyaFaer IlyaFaer left review comments
@olavloite olavloite olavloite approved these changes
@c24t c24t c24t approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mf2199 @olavloite @IlyaFaer @c24t @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.