diff --git a/_multibuild b/_multibuild
new file mode 100644
index 0000000..fcc7b97
--- /dev/null
+++ b/_multibuild
@@ -0,0 +1,3 @@
+
+ test
+
diff --git a/python-google-cloud-spanner.changes b/python-google-cloud-spanner.changes
index 4fb8ea8..18e83d1 100644
--- a/python-google-cloud-spanner.changes
+++ b/python-google-cloud-spanner.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Wed Jan 10 10:05:24 UTC 2024 - Daniel Garcia
+
+- Run tests using multibuild
+
-------------------------------------------------------------------
Tue Jan 9 07:36:26 UTC 2024 - Daniel Garcia
diff --git a/python-google-cloud-spanner.spec b/python-google-cloud-spanner.spec
index 45a3a6c..48c3201 100644
--- a/python-google-cloud-spanner.spec
+++ b/python-google-cloud-spanner.spec
@@ -1,5 +1,5 @@
#
-# spec file for package python-google-cloud-spanner
+# spec file
#
# Copyright (c) 2024 SUSE LLC
#
@@ -16,8 +16,17 @@
#
+%global flavor @BUILD_FLAVOR@%{nil}
+%if "%{flavor}" == "test"
+%define psuffix -test
+%bcond_without test
+%else
+%define psuffix %{nil}
+%bcond_with test
+%endif
+
%{?sle15_python_module_pythons}
-Name: python-google-cloud-spanner
+Name: python-google-cloud-spanner%{psuffix}
Version: 3.40.1
Release: 0
Summary: Google Cloud Spanner API client library
@@ -29,13 +38,17 @@ BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: python-rpm-macros
# SECTION test requirements
+%if %{with test}
BuildRequires: %{python_module google-api-core >= 1.34.0}
BuildRequires: %{python_module google-cloud-core >= 1.4.1}
+BuildRequires: %{python_module google-cloud-spanner = %{version}}
BuildRequires: %{python_module grpc-google-iam-v1 >= 0.12.4}
BuildRequires: %{python_module proto-plus >= 1.22.0}
BuildRequires: %{python_module protobuf >= 3.19.5}
+BuildRequires: %{python_module pytest-asyncio}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module sqlparse >= 0.4.4}
+%endif
# /SECTION
BuildRequires: fdupes
Requires: python-google-api-core >= 1.34.0
@@ -57,20 +70,28 @@ Google Cloud Spanner API client library
%prep
%autosetup -p1 -n google-cloud-spanner-%{version}
+# don't use python-mock
+for i in $(find tests -name "*.py")
+do
+ sed -i 's/^import mock/from unittest import mock/g' $i
+done
+
%build
%pyproject_wheel
%install
+%if %{without test}
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%endif
%check
-echo 0
-# TODO: enable tests. I need to find a way to fix the python path
-# because it loads the /usr/lib/$python/site-packages/google for
-# dependencies and there it can't find the new package.
-#%%pytest
+%if %{with test}
+export GOOGLE_CLOUD_PROJECT="PROJECT"
+%pytest -x tests/unit
+%endif
+%if %{without test}
%files %{python_files}
%doc README.rst
%license LICENSE
@@ -78,5 +99,6 @@ echo 0
%{python_sitelib}/google_cloud_spanner-%{version}-*-nspkg.pth
%{python_sitelib}/google/cloud/spanner*
%{python_sitelib}/google_cloud_spanner-%{version}.dist-info
+%endif
%changelog