Commits

Olemis Lang committed 4f2c880

BH Multiproduct #532 : PostgreSQL test env setup prior to dealing with cluster fixtures and discovery

Comments (0)

Files changed (2)

 t387/t387_r1515319_functional_test.7.diff
 t387/t387_r1526822_functional_test.8.diff
 t532/t532_r1529237_functional_test_entry_points.diff
+t532/t532_r1529237_functional_test.postgres.diff
 t387/t387_r1524640_no_r5994.diff

t532/t532_r1529237_functional_test.postgres.diff

+# HG changeset patch
+# Parent c8a9cb668889b64ed4e66b5a5ab2acbb642f419d
+BH Multiproduct #532 : Functonal tests entry points for PostgreSQL
+
+diff -r c8a9cb668889 bloodhound_multiproduct/tests/functional/__init__.py
+--- a/bloodhound_multiproduct/tests/functional/__init__.py	Mon Oct 07 16:56:36 2013 -0500
++++ b/bloodhound_multiproduct/tests/functional/__init__.py	Tue Oct 08 01:56:34 2013 -0500
+@@ -1051,8 +1051,9 @@
+     return suite
+ 
+ 
+-def test_suite():
+-    suite = functionalSuite()
++def test_suite(suite=None):
++    if suite is None:
++        suite = functionalSuite()
+ 
+     # TODO: Load Bloodhound-specific functional test cases
+ 
+diff -r c8a9cb668889 bloodhound_multiproduct/tests/functional/main/postgres.py
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/bloodhound_multiproduct/tests/functional/main/postgres.py	Tue Oct 08 01:56:34 2013 -0500
+@@ -0,0 +1,89 @@
++# -*- coding: utf-8 -*-
++#
++#  Licensed to the Apache Software Foundation (ASF) under one
++#  or more contributor license agreements.  See the NOTICE file
++#  distributed with this work for additional information
++#  regarding copyright ownership.  The ASF licenses this file
++#  to you under the Apache License, Version 2.0 (the
++#  "License"); you may not use this file except in compliance
++#  with the License.  You may obtain a copy of the License at
++#
++#   http://www.apache.org/licenses/LICENSE-2.0
++#
++#  Unless required by applicable law or agreed to in writing,
++#  software distributed under the License is distributed on an
++#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++#  KIND, either express or implied.  See the License for the
++#  specific language governing permissions and limitations
++#  under the License.
++
++"""Entry point to run Apache(TM) Bloodhound test suite against PostgreSQL DB.
++"""
++
++from trac.db.api import _parse_db_str
++
++from tests import functional
++
++
++class PostgresTestEnvMixin(object):
++    """PostgreSQL functional test.
++
++    It must be mixed with a sub-class of 
++    tests.functional.MultiproductFunctionalMixin or equivalent.
++    """
++    def _detect_postgres(self):
++        """Try to detect PostgreSQL local instance.
++
++        :return:                  a mapping populated with server information
++        :raise EnvironmentError:  if no server or multiple servers are detected
++        """
++        raise EnvironmentError('Unable to detect PostgreSQL server')
++
++    def _setup_postgres(self):
++        """Create PostgreSQL DB to use for this test run
++
++        No modifications will be performed upon pg_hba.conf to configure
++        md5 authentication for local connections.
++
++        :return:                  postgres: DB URI string
++
++        Important:  The target database will not be destroyed at the end of the
++                    test run in order to facilitate post-mortem analysis.
++        """
++
++    @property
++    def _bloodhound_install_args(self):
++        """Initialize arguments supplied in to Bloodhound installer with 
++        PostgreSQL DB URI.
++        """
++        args = super(PostgresTestEnvMixin, self)._bloodhound_install_args
++
++        scheme = dbprop = None
++        dburi = args.get('dbstring')
++        if dburi:
++           scheme, dbprop = _parse_db_str()
++        if scheme != 'postgres':
++            dburi = self._setup_postgres()
++            dburi['dbstring'] = dburi
++        return args
++
++
++class PostgresTestSuite(functional.MultiproductFunctionalTestSuite):
++    """PostgreSQL functional test suite.
++
++    This TestSuite class leverages a test fixture containing a
++    FunctionalTestEnvironment and a FunctionalTester by also
++    upgrading them to multi-product support after activating Bloodhound theme
++    and dashboard plugins.
++    """
++
++
++def functionalSuite():
++    return PostgresTestSuite() 
++
++def test_suite():
++    return functional.test_suite(functionalSuite())
++
++if __name__ == '__main__':
++    unittest.main(defaultTest='test_suite')
++
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.