示例#1
0
文件: test_image.py 项目: CCI-MOC/m2
from unittest import TestCase

from ims.common import config
config.load()

from ims.common.log import trace
from ims.database.database import Database
from ims.exception import db_exceptions


class TestInsert(TestCase):
    """ Creates a project and tests inserting images """
    @trace
    def setUp(self):
        self.db = Database()
        self.db.project.insert('project 1')

    def runTest(self):
        self.db.image.insert('image 1', 1)
        self.db.image.insert('image 2', 1, is_public=True)
        self.db.image.insert('image 3', 1, parent_id=1)
        self.db.image.insert('image 4', 1, is_snapshot=True, parent_id=1)

        images = self.db.image.fetch_images_from_project('project 1')
        self.assertTrue('image 1' in images and 'image 2' in images)

        images = self.db.image.fetch_clones_from_project('project 1')
        self.assertTrue('image 3' in [img[0] for img in images])

        snapshots = self.db.image.fetch_snapshots_from_project('project 1')
        self.assertTrue('image 4' in [snapshot[0] for snapshot in snapshots])
示例#2
0
 def tearDown(self):
     config.load(force=True)
示例#3
0
from unittest import TestCase

from ims.common import config
config.load()

from ims.common.log import trace
from ims.database.database import Database


class TestInsert(TestCase):
    """ Inserts Project """

    @trace
    def setUp(self):
        self.db = Database()

    def runTest(self):
        self.db.project.insert('project 1', 'network 1')

        projects = self.db.project.fetch_projects()

        self.assertEqual('project 1', projects[0][1])

    def tearDown(self):
        self.db.project.delete_with_name('project 1')
        self.db.close()


class TestDelete(TestCase):
    """ Inserts and Deletes Project """
示例#4
0
 def setUp(self):
     self.old_path = os.getenv('BMI_CONFIG')
     os.environ['BMI_CONFIG'] = "tests/unit/common/sample.cfg"
     config.load(force=True)
示例#5
0
 def runTest(self):
     os.environ['BMI_CONFIG'] = self.old_path
     config.load()
     cfg = config.get()
     self.assertEqual(cfg.tests.var1, '0')
示例#6
0
 def runTest(self):
     config.load(force=True)
     cfg = config.get()
     self.assertEqual(cfg.tests.var1, '0')
示例#7
0
 def tearDown(self):
     os.environ['BMI_CONFIG'] = self.old_path
     config.load(force=True)
示例#8
0
 def tearDown(self):
     config.load(force=True)
示例#9
0
 def runTest(self):
     with self.assertRaises(IOError):
         config.load(force=True)
示例#10
0
 def runTest(self):
     os.environ['BMI_CONFIG'] = self.old_path
     config.load()
     cfg = config.get()
     self.assertEqual(cfg.tests.var1, '0')
示例#11
0
 def setUp(self):
     self.old_path = os.getenv('BMI_CONFIG')
     os.environ['BMI_CONFIG'] = "tests/unit/common/sample.cfg"
     config.load(force=True)
示例#12
0
 def tearDown(self):
     os.environ['BMI_CONFIG'] = self.old_path
     config.load(force=True)
示例#13
0
 def runTest(self):
     config.load(force=True)
     cfg = config.get()
     self.assertEqual(cfg.tests.var1, '0')
示例#14
0
 def runTest(self):
     with self.assertRaises(IOError):
         config.load(force=True)