From: Stas Shtin Date: Tue, 20 Apr 2010 14:22:43 +0000 (+0400) Subject: Adding support for DB access from unit tests X-Git-Url: http://git.maemo.org/git/?p=ipypbx;a=commitdiff_plain;h=bd5981b657ca38beb48faca23950ead346da102d Adding support for DB access from unit tests --- diff --git a/src/ipypbx/tests/support.py b/src/ipypbx/tests/support.py new file mode 100644 index 0000000..8cde219 --- /dev/null +++ b/src/ipypbx/tests/support.py @@ -0,0 +1,32 @@ +# Copyright (c) Stas Shtin, 2010 + +# This file is part of IPyPBX. + +# IPyPBX is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# IPyPBX is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with IPyPBX. If not, see . + +from ipypbx import main + +class InitDatabase(object): + _tables = ( + 'connection', 'sipprofile', 'domain', 'gateway', 'endpoint', + 'extension') + + @classmethod + def setUpClass(cls): + cls.db, _created = main.setupDb(dbname=':memory:') + + def setUp(self): + for table in self._tables: + self.db.exec_('delete from ipypbxweb_%s' % table) + diff --git a/src/ipypbx/tests/test_http.py b/src/ipypbx/tests/test_http.py index 47251c2..180b124 100644 --- a/src/ipypbx/tests/test_http.py +++ b/src/ipypbx/tests/test_http.py @@ -17,6 +17,7 @@ import unittest from ipypbx import http +from ipypbx.tests import support class TestHttpRequestParser(unittest.TestCase): @@ -124,3 +125,6 @@ class TestHttpRequestParser(unittest.TestCase): 'Only post requests work') +class TestFreeswitchConfigGenerator(support.InitDatabase, unittest.TestCase): + def test_foo(self): + print self.db