backend/server/rhnSQL/driver_postgresql.py | 2 ++
backend/spacewalk-backend.spec | 9 ++++++++-
backend/test/db_settings.ini | 5 +++++
backend/test/non-unit/server/rhnSQL/dbtests.py | 7 +++++--
backend/test/runtests-postgresql.py | 21 +++++++++++++--------
client/rhel/rhnlib/rhn/UserDictCase.py | 2 --
rel-eng/packages/spacewalk-backend | 2 +-
7 files changed, 34 insertions(+), 14 deletions(-)
New commits:
commit b78f797a86ce3dc62eee914aeece5550a4208ea7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Oct 4 12:51:41 2013 +0200
Automatic commit of package [spacewalk-backend] release [2.1.26-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 5938859..30dbcba 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -11,7 +11,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2
-Version: 2.1.25
+Version: 2.1.26
Release: 1%{?dist}
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -628,6 +628,13 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$
%changelog
+* Fri Oct 04 2013 Michael Mraka <michael.mraka(a)redhat.com> 2.1.26-1
+- Python pgsql db tests: fix broken test
+- Fixed errors inside of the python pgsql test suite.
+- Python pgsql driver: handled ProgrammingError exceptions
+- Python db tests: moved connection settings to dedicated file
+- Fixed script which runs python PostgreSQL tests
+
* Wed Oct 02 2013 Michael Mraka <michael.mraka(a)redhat.com> 2.1.25-1
- 923338 - replace application code with database lookup to prevent conflicting
inserts
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index 7bfb0f0..766160c 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-2.1.25-1 backend/
+2.1.26-1 backend/
commit a5d90e2dad95fcf69464504a2b21bd053cd8b263
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 4 10:55:06 2013 +0200
Python pgsql db tests: fix broken test
The psycopg2 library raises a `KeyError` when a some of the named
parameters of a prepared statement are not given.
diff --git a/backend/test/non-unit/server/rhnSQL/dbtests.py
b/backend/test/non-unit/server/rhnSQL/dbtests.py
index 32f722e..ff51148 100644
--- a/backend/test/non-unit/server/rhnSQL/dbtests.py
+++ b/backend/test/non-unit/server/rhnSQL/dbtests.py
@@ -66,7 +66,7 @@ class RhnSQLDatabaseTests(unittest.TestCase):
query = "INSERT INTO %s(id, name) VALUES(:id, :name)" % \
self.temp_table
cursor = rhnSQL.prepare(query)
- self.assertRaises(sql_base.SQLError, cursor.execute, name="Blah")
+ self.assertRaises(KeyError, cursor.execute, name="Blah")
def test_statement_prepare_error(self):
rhnSQL.transaction("test_statement_prepare_error")
commit 251005196b02b18afd9b1215e8b6c0cc78b5d4d8
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 4 10:55:05 2013 +0200
Python: fixed UserDictCase behaviour when key is not found
The `UserDictCase` class is a dictionary with case insensitive keys.
Since it's inherited from `UserDict` it can be passed to method/functions
expecting a "classic" python dictionary.
Unfortunately `UserDictCase` behaved in a different way when the specified key
was not found: rather than raising a `KeyError` exception it just returned
`None`. That broke duck typing in some places where a `KeyError` was
expected and it also hid errors in other parts of the code (because no exception
was being raised).
This commit ensures `UserDictCase` has the same behaviour of python's
dictionary. The change could break some parts of the code which took
this bug as a feature.
The python unit tests under 'backend/test' and
'backend/satellite_tools' are
still passing.
diff --git a/client/rhel/rhnlib/rhn/UserDictCase.py
b/client/rhel/rhnlib/rhn/UserDictCase.py
index cb55674..c4b8dd6 100644
--- a/client/rhel/rhnlib/rhn/UserDictCase.py
+++ b/client/rhel/rhnlib/rhn/UserDictCase.py
@@ -41,8 +41,6 @@ class UserDictCase(UserDict):
def __getitem__(self, key):
key = self.__lower_string(key)
- if not self.data.has_key(key):
- return None
return self.data[key]
get = __getitem__
commit 3dc37f6101ff683cffe54959ff08095bcad87d11
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 4 10:55:04 2013 +0200
Fixed errors inside of the python pgsql test suite.
Wrapped the 'test_statement_prepare_error' test inside of a transaction,
that leaves the database in a clean state after the
`rhnSQL.SQLStatementPrepareError` exception is raised.
diff --git a/backend/test/non-unit/server/rhnSQL/dbtests.py
b/backend/test/non-unit/server/rhnSQL/dbtests.py
index 1be2c77..32f722e 100644
--- a/backend/test/non-unit/server/rhnSQL/dbtests.py
+++ b/backend/test/non-unit/server/rhnSQL/dbtests.py
@@ -69,11 +69,14 @@ class RhnSQLDatabaseTests(unittest.TestCase):
self.assertRaises(sql_base.SQLError, cursor.execute, name="Blah")
def test_statement_prepare_error(self):
+ rhnSQL.transaction("test_statement_prepare_error")
+
query = "aaa bbb ccc"
cursor = rhnSQL.prepare(query)
self.assertRaises(rhnSQL.SQLStatementPrepareError,
cursor.execute)
- rhnSQL.rollback()
+
+ rhnSQL.rollback("test_statement_prepare_error")
def test_execute_bindbyname_extra_params_passed(self):
query = "SELECT * FROM %s WHERE id = :id" % self.temp_table
commit ae7c7733859b5db8e0a659fa5c9ee73764b7ae87
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 4 10:55:03 2013 +0200
Python pgsql driver: handled ProgrammingError exceptions
Handled psycopg2.ProgramminError exceptions inside of the python pgsql
driver. Raise them as sql_base.SQLStatementPrepareError.
This is commit fixes the 'test_statement_prepare_error' test.
diff --git a/backend/server/rhnSQL/driver_postgresql.py
b/backend/server/rhnSQL/driver_postgresql.py
index d467dca..c284ca0 100644
--- a/backend/server/rhnSQL/driver_postgresql.py
+++ b/backend/server/rhnSQL/driver_postgresql.py
@@ -277,6 +277,8 @@ class Cursor(sql_base.Cursor):
if m:
error_code = int(m.group(1))
raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
+ except psycopg2.ProgrammingError, e:
+ raise sql_base.SQLStatementPrepareError(self.dbh, e.pgerror, self.sql)
return retval
def _execute_(self, args, kwargs):
commit f2e0d4ccb44cef5cc6c9807f145e20cd161ffc06
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 4 10:55:02 2013 +0200
Python db tests: moved connection settings to dedicated file
Moved PostgreSQL connection settings into a dedicated configuration file. This
makes easier to use different connection parameters since it's no longer
needed to change the python source code.
diff --git a/backend/test/db_settings.ini b/backend/test/db_settings.ini
new file mode 100644
index 0000000..10e417f
--- /dev/null
+++ b/backend/test/db_settings.ini
@@ -0,0 +1,5 @@
+[postgresql]
+host: localhost
+user: dgoodwin
+password: spacewalk
+database: spacewalk
diff --git a/backend/test/runtests-postgresql.py b/backend/test/runtests-postgresql.py
index 427c2f7..0a10ec7 100755
--- a/backend/test/runtests-postgresql.py
+++ b/backend/test/runtests-postgresql.py
@@ -23,6 +23,7 @@ import os
import sys
import unittest
+from ConfigParser import ConfigParser
from spacewalk.server import rhnSQL
# Import all test modules here:
@@ -32,10 +33,13 @@ sys.path.insert(
)
import dbtests
-PG_HOST = "localhost"
-PG_USER = "dgoodwin"
-PG_PASSWORD = "spacewalk"
-PG_DATABASE = "spacewalk"
+config = ConfigParser()
+config.read(os.path.dirname(os.path.abspath(__file__)) + "/db_settings.ini")
+
+PG_HOST = config.get('postgresql', 'host')
+PG_USER = config.get('postgresql', 'user')
+PG_PASSWORD= config.get('postgresql', 'password')
+PG_DATABASE = config.get('postgresql', 'database')
rhnSQL.initDB(backend="postgresql", host=PG_HOST, username=PG_USER,
password=PG_PASSWORD, database=PG_DATABASE)
commit ef5e6e585b003426e392dc34c11270df5d007363
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 4 10:55:01 2013 +0200
Fixed script which runs python PostgreSQL tests
The script which starts the python PostgreSQL tests was broken because it
didn't find some required resources, plus it looked for files/directories which
are no longer available.
diff --git a/backend/test/runtests-postgresql.py b/backend/test/runtests-postgresql.py
index 94426f6..427c2f7 100755
--- a/backend/test/runtests-postgresql.py
+++ b/backend/test/runtests-postgresql.py
@@ -19,16 +19,17 @@
Non-pure tests requiring connectivity to a PostgreSQL server configured below.
"""
+import os
import sys
import unittest
-sys.path.insert(0, '../')
-sys.path.insert(0, './suites/')
-sys.path.insert(0, '../../client/rhel/rhnlib')
-
from spacewalk.server import rhnSQL
# Import all test modules here:
+sys.path.insert(
+ 0,
+ os.path.abspath(os.path.dirname(os.path.abspath(__file__) +
"/../non-unit/server/rhnSQL/"))
+)
import dbtests
PG_HOST = "localhost"