|
| 1 | +# Copyright The IETF Trust 2007, All Rights Reserved |
| 2 | + |
| 3 | +# Portion Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 | +# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com> |
| 5 | +# |
| 6 | +# Redistribution and use in source and binary forms, with or without |
| 7 | +# modification, are permitted provided that the following conditions |
| 8 | +# are met: |
| 9 | +# |
| 10 | +# * Redistributions of source code must retain the above copyright |
| 11 | +# notice, this list of conditions and the following disclaimer. |
| 12 | +# |
| 13 | +# * Redistributions in binary form must reproduce the above |
| 14 | +# copyright notice, this list of conditions and the following |
| 15 | +# disclaimer in the documentation and/or other materials provided |
| 16 | +# with the distribution. |
| 17 | +# |
| 18 | +# * Neither the name of the Nokia Corporation and/or its |
| 19 | +# subsidiary(-ies) nor the names of its contributors may be used |
| 20 | +# to endorse or promote products derived from this software |
| 21 | +# without specific prior written permission. |
| 22 | +# |
| 23 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 24 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 25 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 26 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 27 | +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 28 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 29 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 30 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 31 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 32 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 33 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | + |
| 35 | +import django |
| 36 | +from django.db import connection |
| 37 | +import ietf |
| 38 | + |
| 39 | +class RealDatabaseTest: |
| 40 | + def setUpRealDatabase(self): |
| 41 | + self._original_testdb = self._getDatabaseName() |
| 42 | + newdb = ietf.settings.DATABASE_NAME |
| 43 | + print "Switching database from "+self._original_testdb+" to "+newdb |
| 44 | + self._setDatabaseName(newdb) |
| 45 | + |
| 46 | + def tearDownRealDatabase(self): |
| 47 | + curdb = self._getDatabaseName() |
| 48 | + print "Switching database from "+curdb+" to "+self._original_testdb |
| 49 | + self._setDatabaseName(self._original_testdb) |
| 50 | + |
| 51 | + def _getDatabaseName(self): |
| 52 | + if django.VERSION[0] == 0: |
| 53 | + return django.conf.settings.DATABASE_NAME |
| 54 | + else: |
| 55 | + return connection.settings_dict['DATABASE_NAME'] |
| 56 | + |
| 57 | + def _setDatabaseName(self, name): |
| 58 | + connection.close() |
| 59 | + if django.VERSION[0] == 0: |
| 60 | + django.conf.settings.DATABASE_NAME = name |
| 61 | + else: |
| 62 | + connection.settings_dict['DATABASE_NAME'] = name |
| 63 | + connection.cursor() |
0 commit comments