Package: python-sqlalchemy-utils
Version: 0.36.3-3
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu groovy ubuntu-patch

Dear Maintainer,

In an attempt to improve the reliability of the sqlalchemy-utils
package, I've added autopkgtests to ensure that the tests are runnable
rather than skipping all testing.

*** /tmp/tmpwwcschk3/bug_body

In Ubuntu, the attached patch was applied to achieve the following:

  * Enable autopkgtests for python-sqlalchemy-utils.
    - d/rules: Run tests in autopkgtests.
    - d/t/control: Configure functional tests.
    - d/t/python-sqlalchemy-utils: Setup and run functional tests.
    - d/p/disable-dateutil-tests.patch: Remove dateutil tests.
    - d/rules: Add note that we execute tests in autopkgtests.


Thanks for considering the patch.


-- System Information:
Debian Release: bullseye/sid
  APT prefers groovy
  APT policy: (500, 'groovy')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-29-generic (SMP w/8 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
python-sqlalchemy-utils-0.36.3/debian/patches/disable-dateutil-tests.patch 
python-sqlalchemy-utils-0.36.3/debian/patches/disable-dateutil-tests.patch
--- python-sqlalchemy-utils-0.36.3/debian/patches/disable-dateutil-tests.patch  
1970-01-01 01:00:00.000000000 +0100
+++ python-sqlalchemy-utils-0.36.3/debian/patches/disable-dateutil-tests.patch  
2020-07-28 08:35:39.000000000 +0200
@@ -0,0 +1,40 @@
+Description: python-dateutil is broken without a timezone gzip.
+Author: Chris MacNaughton <chris.macnaugh...@canonical.com>
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1887664
+Forwarded: not-needed
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/tests/types/test_timezone.py
++++ b/tests/types/test_timezone.py
+@@ -11,9 +11,6 @@ def Visitor(Base):
+     class Visitor(Base):
+         __tablename__ = 'visitor'
+         id = sa.Column(sa.Integer, primary_key=True)
+-        timezone_dateutil = sa.Column(
+-            timezone.TimezoneType(backend='dateutil')
+-        )
+         timezone_pytz = sa.Column(
+             timezone.TimezoneType(backend='pytz')
+         )
+@@ -32,21 +29,16 @@ class TestTimezoneType(object):
+ 
+     def test_parameter_processing(self, session, Visitor):
+         visitor = Visitor(
+-            timezone_dateutil=u'America/Los_Angeles',
+             timezone_pytz=u'America/Los_Angeles'
+         )
+ 
+         session.add(visitor)
+         session.commit()
+ 
+-        visitor_dateutil = session.query(Visitor).filter_by(
+-            timezone_dateutil=u'America/Los_Angeles'
+-        ).first()
+         visitor_pytz = session.query(Visitor).filter_by(
+             timezone_pytz=u'America/Los_Angeles'
+         ).first()
+ 
+-        assert visitor_dateutil is not None
+         assert visitor_pytz is not None
+ 
+ 
diff -Nru python-sqlalchemy-utils-0.36.3/debian/patches/series 
python-sqlalchemy-utils-0.36.3/debian/patches/series
--- python-sqlalchemy-utils-0.36.3/debian/patches/series        1970-01-01 
01:00:00.000000000 +0100
+++ python-sqlalchemy-utils-0.36.3/debian/patches/series        2020-07-28 
08:35:39.000000000 +0200
@@ -0,0 +1 @@
+disable-dateutil-tests.patch
diff -Nru python-sqlalchemy-utils-0.36.3/debian/rules 
python-sqlalchemy-utils-0.36.3/debian/rules
--- python-sqlalchemy-utils-0.36.3/debian/rules 2020-05-08 11:44:02.000000000 
+0200
+++ python-sqlalchemy-utils-0.36.3/debian/rules 2020-07-28 08:35:39.000000000 
+0200
@@ -10,6 +10,7 @@
 
 override_dh_auto_test:
 ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
+       # autopkg tests are configured to setup dependencies and run tests
        echo "Do not run tests right now:"
        echo "need to setup mysql and postgres before running them"
        echo "and set SQLALCHEMY_UTILS_TEST_DB 
SQLALCHEMY_UTILS_TEST_POSTGRESQL_USER SQLALCHEMY_UTILS_TEST_MYSQL_USER"
diff -Nru python-sqlalchemy-utils-0.36.3/debian/tests/control 
python-sqlalchemy-utils-0.36.3/debian/tests/control
--- python-sqlalchemy-utils-0.36.3/debian/tests/control 1970-01-01 
01:00:00.000000000 +0100
+++ python-sqlalchemy-utils-0.36.3/debian/tests/control 2020-07-28 
08:35:19.000000000 +0200
@@ -0,0 +1,12 @@
+Tests: python-sqlalchemy-utils
+Depends:
+ @, @builddeps@,
+ mysql-server,
+ postgresql-all,
+ python3-colour,
+ python3-cryptography,
+ python3-phonenumbers,
+ python3-pg,
+ python3-pg8000,
+Restrictions: needs-root, allow-stderr
+
diff -Nru python-sqlalchemy-utils-0.36.3/debian/tests/python-sqlalchemy-utils 
python-sqlalchemy-utils-0.36.3/debian/tests/python-sqlalchemy-utils
--- python-sqlalchemy-utils-0.36.3/debian/tests/python-sqlalchemy-utils 
1970-01-01 01:00:00.000000000 +0100
+++ python-sqlalchemy-utils-0.36.3/debian/tests/python-sqlalchemy-utils 
2020-07-28 08:35:19.000000000 +0200
@@ -0,0 +1,29 @@
+#!/bin/bash
+#---------------------
+# Testing sqlalchemy-utils
+#---------------------
+ret=0
+
+# Prepare Postgres and Mysql
+sed  -i 's/local\s\+all\s\+postgres\s\+peer/local all postgres trust\nhost all 
postgres 127.0.0.1\/32 trust/' /etc/postgresql/*/main/pg_hba.conf
+echo "default-authentication-plugin=mysql_native_password" >> 
/etc/mysql/mysql.conf.d/mysqld.cnf
+systemctl restart postgresql
+systemctl restart mysql
+
+# Cleanup existing test databases
+psql -c 'drop database sqlalchemy_utils_test;' -U postgres
+mysql -e 'drop database sqlalchemy_utils_test;'
+mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password 
BY '';"
+
+set -e
+# Setup test databases
+psql -c 'create database sqlalchemy_utils_test;' -U postgres
+psql -c 'create extension hstore;' -d sqlalchemy_utils_test -U postgres
+mysql -e 'create database sqlalchemy_utils_test;'
+
+export SQLALCHEMY_UTILS_TEST_MYSQL_USER="root"
+export SQLALCHEMY_UTILS_TEST_POSTGRESQL_USER="postgres"
+export SQLALCHEMY_UTILS_TEST_DB="sqlalchemy_utils_test"
+
+# Run tests
+pytest-3 sqlalchemy_utils tests

Reply via email to