示例#1
0
 def test_get_healthnmon_location(self):
     healthnmon_package_loc = healthnmon.get_healthnmon_location()
     self.assertNotEqual(healthnmon_package_loc, None)
     init_file_path = os.path.join(healthnmon_package_loc, '__init__.py')
     init_exists = os.path.exists(init_file_path)
     self.assertTrue(
         init_exists,
         _('__init__.py file not existing in %s' % healthnmon_package_loc))
示例#2
0
 def test_get_healthnmon_location(self):
     healthnmon_package_loc = healthnmon.get_healthnmon_location()
     self.assertNotEqual(healthnmon_package_loc, None)
     init_file_path = os.path.join(healthnmon_package_loc,
                                   '__init__.py')
     init_exists = os.path.exists(init_file_path)
     self.assertTrue(init_exists,
                     _('__init__.py file not existing in %s'
                     % healthnmon_package_loc))
示例#3
0
def setup():
    ''' for nova test.py create a dummy clean.sqlite '''
    healthnmon_path = os.path.abspath(
        os.path.join(healthnmon.get_healthnmon_location(), '../'))
    cleandb = os.path.join(healthnmon_path, CONF.sqlite_clean_db)
    if os.path.exists(cleandb):
        pass
    else:
        open(cleandb, 'w').close()

    ''' for healthnmon create db '''
    healthnmon_path = os.path.abspath(
        os.path.join(healthnmon.get_healthnmon_location(), '../'))
    sql_connection_url = "sqlite:///" + str(healthnmon_path) + "/$sqlite_db"
    CONF.set_default("sql_connection", sql_connection_url)
    testdb = os.path.join(healthnmon_path, CONF.sqlite_db)
    if os.path.exists(testdb):
        return
    nova_migration.db_sync()
    healthnmon_migration.db_sync()
    cleandb = os.path.join(healthnmon_path, CONF.sqlite_clean_db)
    shutil.copyfile(testdb, cleandb)
示例#4
0
def setup():
    ''' for nova test.py create a dummy clean.sqlite '''
    cleandb = os.path.join(CONF.state_path, CONF.sqlite_clean_db)
    if os.path.exists(cleandb):
        pass
    else:
        open(cleandb, 'w').close()
    ''' for healthnmon create db '''
    healthnmon_path = os.path.abspath(
        os.path.join(healthnmon.get_healthnmon_location(), '../'))
    sql_connection_url = "sqlite:///" + str(healthnmon_path) + "/$sqlite_db"
    CONF.set_default("sql_connection", sql_connection_url)
    testdb = os.path.join(healthnmon_path, CONF.sqlite_db)
    if os.path.exists(testdb):
        return
    nova_migration.db_sync()
    healthnmon_migration.db_sync()
    cleandb = os.path.join(healthnmon_path, CONF.sqlite_clean_db)
    shutil.copyfile(testdb, cleandb)
示例#5
0
文件: test.py 项目: emonty/healthnmon
#    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.


from nova.openstack.common import cfg
import unittest
import os
import logging
import shutil
import healthnmon

healthnmon_path = os.path.abspath(
    os.path.join(healthnmon.get_healthnmon_location(), '../'))

CONF = cfg.CONF


class TestCase(unittest.TestCase):

    """Base class for all DB unit tests."""

    def setUp(self):
        """Run before each test method to initialize DB"""
        logging.basicConfig()
        super(TestCase, self).setUp()
        shutil.copyfile(os.path.join(healthnmon_path, CONF.sqlite_clean_db),
                        os.path.join(healthnmon_path, CONF.sqlite_db))
示例#6
0
#
#         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.

from nova.openstack.common import cfg
import unittest
import os
import logging
import shutil
import healthnmon

healthnmon_path = os.path.abspath(
    os.path.join(healthnmon.get_healthnmon_location(), '../'))

CONF = cfg.CONF


class TestCase(unittest.TestCase):
    """Base class for all DB unit tests."""
    def setUp(self):
        """Run before each test method to initialize DB"""
        logging.basicConfig()
        super(TestCase, self).setUp()
        shutil.copyfile(os.path.join(healthnmon_path, CONF.sqlite_clean_db),
                        os.path.join(healthnmon_path, CONF.sqlite_db))