This repository was archived by the owner on Mar 31, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
google/cloud/spanner_dbapi Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import pkg_resources
1516import platform
1617
1718PY_VERSION = platform .python_version ()
18- VERSION = "2.2.0a1"
19- DEFAULT_USER_AGENT = "django_spanner /" + VERSION
19+ VERSION = pkg_resources . get_distribution ( "google-cloud-spanner" ). version
20+ DEFAULT_USER_AGENT = "dbapi /" + VERSION
Original file line number Diff line number Diff line change 1414
1515import hashlib
1616import pickle
17+ import pkg_resources
1718
1819import pytest
1920
2021from google .cloud import spanner_v1
21- from google .cloud .spanner_dbapi .connection import Connection
22+ from google .cloud .spanner_dbapi .connection import connect , Connection
2223from . import _helpers
2324
2425DATABASE_NAME = "dbapi-txn"
@@ -357,3 +358,12 @@ def test_ping(shared_instance, dbapi_database):
357358 conn = Connection (shared_instance , dbapi_database )
358359 conn .validate ()
359360 conn .close ()
361+
362+
363+ def test_user_agent (shared_instance , dbapi_database ):
364+ """Check that DB API uses an appropriate user agent."""
365+ conn = connect (shared_instance .name , dbapi_database .name )
366+ assert (
367+ conn .instance ._client ._client_info .user_agent
368+ == "dbapi/" + pkg_resources .get_distribution ("google-cloud-spanner" ).version
369+ )
You can’t perform that action at this time.
0 commit comments