X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwstagingmgr%2Ftest%2Futest_staging_store.py;fp=rwlaunchpad%2Fplugins%2Frwstagingmgr%2Ftest%2Futest_staging_store.py;h=c71d962e1a358e950fe3fc785be22ce03f96cacb;hb=4870d0ee29789b859931e4e2c73e13dcb29537d5;hp=eb71aa39de82c1aeaab6920435201a473ba7bb69;hpb=6f1a3fe149e4a6b9803382cb299c902f4cf58ec9;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwstagingmgr/test/utest_staging_store.py b/rwlaunchpad/plugins/rwstagingmgr/test/utest_staging_store.py index eb71aa39..c71d962e 100755 --- a/rwlaunchpad/plugins/rwstagingmgr/test/utest_staging_store.py +++ b/rwlaunchpad/plugins/rwstagingmgr/test/utest_staging_store.py @@ -26,7 +26,12 @@ import tempfile import unittest import xmlrunner +#Setting RIFT_VAR_ROOT if not already set for unit test execution +if "RIFT_VAR_ROOT" not in os.environ: + os.environ['RIFT_VAR_ROOT'] = os.path.join(os.environ['RIFT_INSTALL'], 'var/rift/unittest') + from rift.tasklets.rwstagingmgr.store import StagingFileStore +from rift.mano.utils.project import ManoProject, DEFAULT_PROJECT import gi gi.require_version('RwStagingMgmtYang', '1.0') @@ -34,6 +39,18 @@ from gi.repository import ( RwStagingMgmtYang, ) +class MockTasklet(object): + def __init__(self): + self.log = logging.getLogger() + self.projects = {} + project = ManoProject(self.log, name=DEFAULT_PROJECT) + project.publisher = None + self.projects[project.name] = project + + def set_delegate(self, store): + self.projects[DEFAULT_PROJECT].publisher = store + + class TestSerializer(unittest.TestCase): def test_staging_area_create(self): @@ -44,9 +61,10 @@ class TestSerializer(unittest.TestCase): """ tmp_dir = tempfile.mkdtemp() - store = StagingFileStore(root_dir=tmp_dir) + tasklet = MockTasklet() + store = StagingFileStore(tasklet, root_dir=tmp_dir) - mock_model = RwStagingMgmtYang.StagingArea.from_dict({}) + mock_model = RwStagingMgmtYang.YangData_RwProject_Project_StagingAreas_StagingArea.from_dict({}) stg = store.create_staging_area(mock_model) mock_id = stg.model.area_id @@ -63,9 +81,10 @@ class TestSerializer(unittest.TestCase): """ tmp_dir = tempfile.mkdtemp() - store = StagingFileStore(root_dir=tmp_dir) + tasklet = MockTasklet() + store = StagingFileStore(tasklet, root_dir=tmp_dir) - mock_model = RwStagingMgmtYang.StagingArea.from_dict({}) + mock_model = RwStagingMgmtYang.YangData_RwProject_Project_StagingAreas_StagingArea.from_dict({}) # get the wrapped mock model mock_model = store.create_staging_area(mock_model) mock_id = mock_model.model.area_id