Skip to content

Conversation

@bhatt4982
Copy link
Contributor

  • Code is combination of both python-spanner and python-spanner-sqlalchemy
  • Added system tests for verification
  • Added nox for project configuration and verification
  • Added workflow to publish to PyPi

@bhatt4982 bhatt4982 requested a review from a team as a code owner December 5, 2025 08:00
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bhatt4982, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new Python library, spannermockserver, designed to provide a lightweight, in-memory mock for Google Cloud Spanner. This mock server is crucial for enabling efficient and isolated testing of applications that interact with Spanner, eliminating the need for a live database connection during development and CI/CD. The changes encompass the core mock server logic, generated gRPC interfaces, comprehensive testing utilities, and robust project management tooling.

Highlights

  • New Spanner Mock Server: Introduced a new Python library, spannermockserver, which provides an in-memory mock server for Google Cloud Spanner, enabling local testing without a live Spanner instance.
  • Code Integration: The mock server's implementation combines logic and concepts from both the python-spanner and python-spanner-sqlalchemy projects.
  • System Tests: Comprehensive system tests have been added to verify the functionality and correctness of the SpannerMockServer.
  • Nox Configuration: Project configuration and verification are now managed using Nox, including sessions for formatting, linting, testing, gRPC code generation, and package building.
  • PyPi Publishing Workflow: A new workflow has been established to facilitate publishing the spannermockserver library to PyPi.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/release-spannermockserver.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@bhatt4982
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive mock server for Google Cloud Spanner, which is a valuable addition for facilitating testing. The implementation includes the core mock logic, gRPC service definitions, helper utilities for tests, and initial system tests. The code is generally well-structured. However, I've identified a critical bug in the mock Spanner logic that could lead to incorrect test behavior, along with some high-severity issues related to unreachable code from incorrect dictionary handling. I've also found several medium-severity issues in the noxfile.py configuration, such as using a non-existent Python version, inconsistent linting rules, and an undefined nox session. The suggested changes aim to fix these bugs and improve the robustness and maintainability of the new mock server.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Python package spannermockserver, a lightweight in-memory mock server for Google Cloud Spanner. The package includes mock implementations for SpannerServicer and DatabaseAdminServicer, along with a noxfile.py for project automation and system tests for verification.

The overall structure is well-organized, and the use of a mock server for testing is a great practice. I've identified a few areas for improvement, primarily concerning potential bugs in the mock implementation and configuration inconsistencies. My main concerns are:

  • A bug in mock_spanner.py that nullifies a transaction parameter.
  • Unsafe dictionary access in the mock servicers that could lead to KeyError exceptions instead of graceful gRPC errors.
  • Inconsistencies in the noxfile.py configuration for linting and session names.

I've provided specific suggestions to address these points. Once these are addressed, this will be a solid foundation for the mock server.

olavloite
olavloite previously approved these changes Dec 8, 2025
Copy link
Collaborator

@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.

LGTM, with some minor nits/requests. These can be picked up in follow-up PRs if that is easier.

@bhatt4982 bhatt4982 merged commit 5fd36d5 into main Dec 9, 2025
43 of 47 checks passed
@bhatt4982 bhatt4982 deleted the sms branch December 9, 2025 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants