tests and fixtures for emulator autorequire
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
6e7ebf6de1
commit
0d05e61b85
9 changed files with 56 additions and 1 deletions
|
|
@ -22,6 +22,7 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
import cdist
|
||||
from cdist import test
|
||||
from cdist.exec import local
|
||||
from cdist import emulator
|
||||
|
|
@ -29,7 +30,6 @@ from cdist import core
|
|||
|
||||
local_base_path = test.cdist_base_path
|
||||
|
||||
|
||||
class EmulatorTestCase(test.CdistTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -73,3 +73,32 @@ class EmulatorTestCase(test.CdistTestCase):
|
|||
os.environ['require'] = '__file/bad/id/with/.cdist/inside'
|
||||
emu = emulator.Emulator(argv)
|
||||
self.assertRaises(core.IllegalObjectIdError, emu.run)
|
||||
|
||||
|
||||
import os.path as op
|
||||
my_dir = op.abspath(op.dirname(__file__))
|
||||
fixtures = op.join(my_dir, 'fixtures')
|
||||
|
||||
class AutoRequireEmulatorTestCase(test.CdistTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = self.mkdtemp()
|
||||
self.target_host = 'localhost'
|
||||
out_path = self.temp_dir
|
||||
_local_base_path = fixtures
|
||||
self.local = local.Local(self.target_host, _local_base_path, out_path)
|
||||
self.local.create_directories()
|
||||
self.local.link_emulator(cdist.test.cdist_exec_path)
|
||||
self.manifest = core.Manifest(self.target_host, self.local)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
def test_autorequire(self):
|
||||
initial_manifest = os.path.join(self.local.manifest_path, "init")
|
||||
self.manifest.run_initial_manifest(initial_manifest)
|
||||
cdist_type = core.Type(self.local.type_path, '__saturn')
|
||||
cdist_object = core.Object(cdist_type, self.local.object_path, 'singleton')
|
||||
self.manifest.run_type_manifest(cdist_object)
|
||||
expected = ['__planet/Saturn', '__moon/Prometheus']
|
||||
self.assertEqual(sorted(cdist_object.requirements), sorted(expected))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue