backend/server/handlers/app/test/test_channel.py | 272 -----------------------
backend/server/rhnSQL/driver_postgresql.py | 4
backend/spacewalk-backend.spec | 9
backend/test/db_settings.ini | 4
backend/test/non-unit/server/rhnSQL/dbtests.py | 40 ---
backend/test/runtests-oracle.py | 56 +++-
rel-eng/packages/spacewalk-backend | 2
7 files changed, 64 insertions(+), 323 deletions(-)
New commits:
commit 2d855013f49045c11883af8cd64e542ebe1af5ce
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Oct 21 10:23:48 2013 +0200
Automatic commit of package [spacewalk-backend] release [2.1.30-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 438aace..cb46590 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.29
+Version: 2.1.30
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*
%{pythonrhnroot}/satellite_tools/exporter/xmlWriter.py*
%changelog
+* Mon Oct 21 2013 Michael Mraka <michael.mraka(a)redhat.com> 2.1.30-1
+- python oracle tests: better integration with nosetest
+- python pgsql driver: behave like the oracle one
+- python oracle tests: moved connection settings to configuration file
+- python oracle tests: fixed import statements
+- removed dead test
+
* Fri Oct 18 2013 Michael Mraka <michael.mraka(a)redhat.com> 2.1.29-1
- include stringutils into package
- replace encode/decode with to_string/to_unicode
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index b8c4508..18910d5 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-2.1.29-1 backend/
+2.1.30-1 backend/
commit d4420c0a54089f9a8e12632ff5b451a10e0aa3cb
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 18 15:20:49 2013 +0200
python oracle tests: better integration with nosetest
Made easier to run python oracle tests using nosetest.
diff --git a/backend/test/non-unit/server/rhnSQL/dbtests.py
b/backend/test/non-unit/server/rhnSQL/dbtests.py
index fd7fa93..101f48f 100644
--- a/backend/test/non-unit/server/rhnSQL/dbtests.py
+++ b/backend/test/non-unit/server/rhnSQL/dbtests.py
@@ -199,41 +199,3 @@ class RhnSQLDatabaseTests(unittest.TestCase):
# ret = sp(5)
# self.assertEquals(5, ret)
-
-
-class OracleDatabaseTests(RhnSQLDatabaseTests):
- QUERY_CREATE_TABLE = """
- CREATE TABLE %s(id NUMBER, name VARCHAR2(256), num NUMBER(5,2))
- """
-
- SIMPLE_PROCEDURE = """
-CREATE OR REPLACE FUNCTION
- return_int(returnme in integer)
-RETURN INTEGER AS
-BEGIN
- RETURN returnme;
-END;
- """
-
- def setUp(self):
- self.set_temp_table()
- create_table_query = self.QUERY_CREATE_TABLE % self.temp_table
- cursor = rhnSQL.prepare(create_table_query)
- cursor.execute()
-
- RhnSQLDatabaseTests.setUp(self)
-
- cursor = rhnSQL.prepare(self.SIMPLE_PROCEDURE)
- cursor.execute()
-
- def tearDown(self):
- cursor = rhnSQL.prepare("DROP FUNCTION return_int")
- cursor.execute()
-
- RhnSQLDatabaseTests.tearDown(self)
-
-def oracle_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(OracleDatabaseTests))
- return suite
-
diff --git a/backend/test/runtests-oracle.py b/backend/test/runtests-oracle.py
index 75fada2..25bee4e 100755
--- a/backend/test/runtests-oracle.py
+++ b/backend/test/runtests-oracle.py
@@ -47,11 +47,42 @@ rhnSQL.initDB(backend="oracle", username=USER,
rhnSQL.initDB(backend="oracle", username=USER,
password=PASSWORD, database=DATABASE)
+class OracleDatabaseTests(dbtests.RhnSQLDatabaseTests):
+ QUERY_CREATE_TABLE = """
+ CREATE TABLE %s(id NUMBER, name VARCHAR2(256), num NUMBER(5,2))
+ """
+
+ SIMPLE_PROCEDURE = """
+CREATE OR REPLACE FUNCTION
+ return_int(returnme in integer)
+RETURN INTEGER AS
+BEGIN
+ RETURN returnme;
+END;
+ """
+
+ def setUp(self):
+ self.set_temp_table()
+ create_table_query = self.QUERY_CREATE_TABLE % self.temp_table
+ cursor = rhnSQL.prepare(create_table_query)
+ cursor.execute()
+
+ dbtests.RhnSQLDatabaseTests.setUp(self)
+
+ cursor = rhnSQL.prepare(self.SIMPLE_PROCEDURE)
+ cursor.execute()
+
+ def tearDown(self):
+ cursor = rhnSQL.prepare("DROP FUNCTION return_int")
+ cursor.execute()
+
+ dbtests.RhnSQLDatabaseTests.tearDown(self)
+
def suite():
+ s = unittest.TestSuite()
+ s.addTest(unittest.makeSuite(OracleDatabaseTests))
# Append all test suites here:
- return unittest.TestSuite((
- dbtests.oracle_suite(),
- ))
+ return unittest.TestSuite(s)
if __name__ == "__main__":
try:
commit 71b80f5d69bcd18677cb40882bf8764fe664dab2
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 18 15:20:48 2013 +0200
python pgsql driver: behave like the oracle one
Ensure the PostgreSQL driver raises a `sql_base.SQLError` when a cursor executes
a query which has unbound variables.
This makes the behaviour of the PostgreSQL driver consistent with the
Oracle one.
diff --git a/backend/server/rhnSQL/driver_postgresql.py
b/backend/server/rhnSQL/driver_postgresql.py
index c284ca0..caa5e25 100644
--- a/backend/server/rhnSQL/driver_postgresql.py
+++ b/backend/server/rhnSQL/driver_postgresql.py
@@ -18,6 +18,7 @@
#
import sys
+import string
import re
import psycopg2
@@ -279,6 +280,9 @@ class Cursor(sql_base.Cursor):
raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
except psycopg2.ProgrammingError, e:
raise sql_base.SQLStatementPrepareError(self.dbh, e.pgerror, self.sql)
+ except KeyError, e:
+ raise sql_base.SQLError("Unable to bound the following variable(s):
%s"
+ % (string.join(e.args, " ")))
return retval
def _execute_(self, args, kwargs):
diff --git a/backend/test/non-unit/server/rhnSQL/dbtests.py
b/backend/test/non-unit/server/rhnSQL/dbtests.py
index 0fa703a..fd7fa93 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(KeyError, cursor.execute, name="Blah")
+ self.assertRaises(sql_base.SQLError, cursor.execute, name="Blah")
def test_statement_prepare_error(self):
rhnSQL.transaction("test_statement_prepare_error")
commit 34c4ec9078c058cdb61e10a3f0e64a16faf0a66b
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 18 15:20:47 2013 +0200
python oracle tests: moved connection settings to configuration file
Moved all the Oracle connection settings to the db_settings.ini file
(like we already do with the PostgreSQL's values).
diff --git a/backend/test/db_settings.ini b/backend/test/db_settings.ini
index 10e417f..79b7f0b 100644
--- a/backend/test/db_settings.ini
+++ b/backend/test/db_settings.ini
@@ -3,3 +3,7 @@ host: localhost
user: dgoodwin
password: spacewalk
database: spacewalk
+[oracle]
+user: spacewalk
+password: spacewalk
+database: xe
diff --git a/backend/test/runtests-oracle.py b/backend/test/runtests-oracle.py
index c13f70f..75fada2 100755
--- a/backend/test/runtests-oracle.py
+++ b/backend/test/runtests-oracle.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,9 +33,12 @@ sys.path.insert(
)
import dbtests
-USER = "spacewalk"
-PASSWORD = "spacewalk"
-DATABASE = "xe"
+config = ConfigParser()
+config.read(os.path.dirname(os.path.abspath(__file__)) + "/db_settings.ini")
+
+USER = config.get('oracle', 'user')
+PASSWORD = config.get('oracle', 'password')
+DATABASE = config.get('oracle', 'database')
rhnSQL.initDB(backend="oracle", username=USER,
password=PASSWORD, database=DATABASE)
commit b0a0165e3c16e3fa6849b9349a48f406b7d920c5
Author: Flavio Castelli <fcastelli(a)suse.com>
Date: Fri Oct 18 15:20:46 2013 +0200
python oracle tests: fixed import statements
Fixed the import statements. This makes possible to run the test suite.
diff --git a/backend/test/runtests-oracle.py b/backend/test/runtests-oracle.py
index cb5f97a..c13f70f 100755
--- a/backend/test/runtests-oracle.py
+++ b/backend/test/runtests-oracle.py
@@ -19,16 +19,17 @@
Non-pure tests requiring connectivity to an Oracle 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
USER = "spacewalk"
commit 433b2086a26bcb0fafb412c9b86d1e3373fcebec
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Oct 12 12:58:46 2012 +0200
removed dead test
app/channel.py has been removed in 1c1faa908c7bf2754c7338895fc567e832f963b9
diff --git a/backend/server/handlers/app/test/test_channel.py
b/backend/server/handlers/app/test/test_channel.py
deleted file mode 100644
index 1e787e3..0000000
--- a/backend/server/handlers/app/test/test_channel.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (c) 2008--2013 Red Hat, Inc.
-#
-# This software is licensed to you under the GNU General Public License,
-# version 2 (GPLv2). There is NO WARRANTY for this software, express or
-# implied, including the implied warranties of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
-# along with this software; if not, see
-#
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
-# Red Hat trademarks are not licensed under GPLv2. No permission is
-# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
-#
-
-import unittest
-from spacewalk.server import rhnSQL
-from spacewalk.common.rhnException import rhnFault
-from spacewalk.server.handlers.app import channel
-
-#setup
-db = 'webdev'
-username = 'praddb'
-password = 'password'
-channel = channel.Channel()
-commit = True
-options = {'verbose': None, 'family': 'prad-channel',
'manage': None,
- 'dist_release': '1.0', 'update_only': None,
'subscribe': None,
- 'summary': 'none', 'create': True,
'end_of_life': None, 'label': 'yy',
- 'csv': None, 'username': 'praddb',
'description': None, 'parent': None,
- 'revoke_manage': None, 'update': None, 'password':
'password',
- 'arch': 'channel-ia32', 'gpg_key_id': None,
'gpg_key_url': None,
- 'name': 'xx', 'gpg_key_fp': None, 'list':
None,
- 'server': 'rhnxml.back-webdev.redhat.com', 'orgId':
None,
- 'revoke_subscribe': None, 'delete': None}
-
-version = options['dist_release']
-
-kargs = {
- 'channel_id' : 217,
- 'channel_arch_id' : 500,
- 'release' : version
- }
-
-class ChannelTestCase(unittest.TestCase):
-
- def setUp(self):
- rhnSQL.initDB()
-
- def tearDown(self):
- rhnSQL.rollback()
-
- def testauth(self):
- try:
- channel._auth(username, password)
- except rhnFault, f:
- None
-
- def testcreatechannel(self):
- params = {'gpg_key_url': '', 'channel_arch_id': 500,
'name': 'xx',
- 'gpg_key_fp': '', 'basedir': '/',
'org_id': '',
- 'end_of_life': '', 'label': 'yy',
'parent_channel': '',
- 'summary': 'none', 'id': 255,
'gpg_key_id': '', 'description': ''}
-
- ret = channel.createChannel(params, commit, username, password)
-
- h = rhnSQL.prepare("""select * from rhnChannel where label = :
label""")
- h.execute(label = params['label'])
-
- ret = h.fetchone_dict() or []
-
- self.assertEqual(ret, [])
-
-
- def testlistchannel(self):
- ret = channel.listChannel(username, password)
-
- self.assertNotEqual(ret, [])
-
- assert type(ret) == type([])
-
- def testupdatechannel(self):
- params = {'gpg_key_url': '', 'channel_arch_id': 500,
'name': 'xx-update', 'gpg_key_fp': '',
- 'basedir': '/', 'org_id': '',
'end_of_life': '', 'label': 'yy',
- 'parent_channel': '', 'summary':
'none', 'id': 255, 'gpg_key_id': '',
- 'description': ''}
-
- h = rhnSQL.prepare("""select id from rhnChannel where label = :
label""")
- h.execute(label = params['label'])
-
- ret = h.fetchone_dict() or []
-
- channel_id = ret['id']
-
- old_channel_family_id = 107
- new_channel_family_id = 109
-
- ret = channel.updateChannel(params, channel_id, old_channel_family_id,
- new_channel_family_id, commit, username, password)
-
- h = rhnSQL.prepare("""select name from rhnChannel where label = :
label""")
- h.execute(label = params['label'])
-
- ret = h.fetchone_dict() or []
- #Errors if the name field is not updated.
- self.assertEqual(ret['name'], params['name'])
-
-
- def testdeletechannel(self):
- channel_id = 5294
- ret = channel.deleteChannel( channel_id, commit, username, password)
-
- h = rhnSQL.prepare("""select * from rhnChannel where id = :
cid""")
- h.execute(cid = channel_id)
-
- ret = h.fetchone_dict() or []
-
- self.assertEqual(ret, [])
-
-
- def testlistchannelfororg(self):
- orgId = 1
- ret = channel.listChannelForOrg(orgId, username, password)
-
- assert type(ret) == type([])
-
- def testlookupchannel(self):
- label = 'aa'
- ret = channel.lookupChannel( label, username, password)
- if ret:
- assert type(ret) == type([])
-
- def testlookupchannelarch(self):
- label = 'aa'
- test_arch = channel.lookupChannelArch(label, username, password)
- assert type(test_arch) == type(1)
-
- def testlookuporgId(self):
- org_id =1
- ret = channel.lookupOrgId(org_id, username, password)
- if ret:
- assert type(ret) == type(1)
-
- def testupdateChannelMembership(self):
- channel_id = 5497
- channel_family_id = 109
- ret = channel.updateChannelMembership(channel_id, channel_family_id, kargs,
commit,
- username, password)
-
- h = rhnSQL.prepare("""select * from rhnChannelFamilyMembers where
channel_id = : cid """)
-
- h.execute(cid = channel_id)
-
- ret = h.fetchone_dict() or []
-
- self.assertNotEqual(ret, [])
-
-
- def testmoveChannelDownloads(self):
- channel_id = 5497
- old_channel_family_id = 107
- new_channel_family_id = 109
- ret = channel.moveChannelDownloads(channel_id, old_channel_family_id,
- new_channel_family_id, username, password)
-
- self.assertEqual(ret, 1)
-
- def testdeleteDist(self):
- channel_id = 505
- ret = channel.deleteDist(channel_id, username, password)
-
- h = rhnSQL.prepare("""select *
- from rhnDistChannelMap
- where channel_id = : cid """)
-
- h.execute(cid = channel_id)
-
- ret = h.fetchone_dict() or []
-
- self.assertEqual(ret, [])
-
- def testupdateDist(self):
- version = options['dist_release']
- kargs = {
- 'channel_id' : 217,
- 'channel_arch_id' : 500,
- 'release' : version
- }
- ret = channel.updateDist(kargs, username, password)
- h = rhnSQL.prepare("""select *
- from rhnDistChannelMap
- where channel_id = : cid """)
-
- h.execute(cid = kargs['channel_id'])
-
- ret = h.fetchone_dict() or []
- self.assertNotEqual(ret, [])
-
- def testchannelManagePermission(self):
- ret1 = channel.channelManagePermission(options['label'],
'manage', commit,
- username, password)
-
- ret2 = channel.channelManagePermission(options['label'],
'subscribe', commit,
- username, password)
-
- h = rhnSQL.prepare("""select id from rhnchannel where label =
:label""")
- h.execute(label = options['label'])
-
- ret = h.fetchone_dict() or []
-
- h2 = rhnSQL.prepare("""
- select cpr.label
- from rhnchannelpermission cp,
- rhnchannelpermissionrole cpr
- where cp.channel_id = :cid
- and cpr.id = cp.role_id
- """)
- h2.execute(cid = ret['id'])
-
- ret2 = h2.fetchone_dict() or []
- if ret2:
- assert ret2['label'] in ['manage', 'subscribe']
-
- def testrevokemanageChannelPermission(self):
- ret = channel.revokeChannelPermission(options['label'], 'manage',
commit,
- username, password)
-
- h = rhnSQL.prepare("""select id from rhnchannel where label =
:label""")
- h.execute(label = options['label'])
-
- ret = h.fetchone_dict() or []
-
- h2 = rhnSQL.prepare("""
- select cpr.label
- from rhnchannelpermission cp,
- rhnchannelpermissionrole cpr
- where cp.channel_id = :cid
- and cpr.id = cp.role_id
- """)
- h2.execute(cid = ret['id'])
-
- ret2 = h2.fetchone_dict() or []
- if ret2:
- assert ret2['label'] != 'manage'
-
-
- def testrevokesubscribeChannelPermission(self):
- ret = channel.revokeChannelPermission(options['label'],
'subscribe', commit,
- username, password)
- h = rhnSQL.prepare("""select id from rhnchannel where label =
:label""")
- h.execute(label = options['label'])
-
- ret = h.fetchone_dict() or []
-
- h2 = rhnSQL.prepare("""
- select cpr.label
- from rhnchannelpermission cp,
- rhnchannelpermissionrole cpr
- where cpr.id = cp.role_id
- and cp.channel_id = :cid
- """)
- h2.execute(cid = ret['id'])
-
- ret2 = h2.fetchone_dict() or []
- if ret2:
- assert ret2['label'] != 'subscribe'
-
-
-if __name__ == "__main__":
- unittest.main()
- rhnSQL.rollback()