tests and fixtures for emulator autorequire

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
remotes/origin/feature_files_export
Steven Armstrong 14 years ago
parent 6e7ebf6de1
commit 0d05e61b85
  1. 31
      lib/cdist/test/emulator/__init__.py
  2. 3
      lib/cdist/test/emulator/fixtures/conf/manifest/init
  3. 8
      lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest
  4. 1
      lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/optional
  5. 1
      lib/cdist/test/emulator/fixtures/conf/type/__moon/parameter/required
  6. 8
      lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest
  7. 1
      lib/cdist/test/emulator/fixtures/conf/type/__planet/parameter/optional
  8. 4
      lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest
  9. 0
      lib/cdist/test/emulator/fixtures/conf/type/__saturn/singleton

@ -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))

@ -0,0 +1,8 @@
#!/bin/sh
if [ -f "$__object/parameter/name" ]; then
name="(cat "$__object/parameter/name")"
else
name="$__object_id"
echo "$name" > "$__object/parameter/name"
fi

@ -0,0 +1,8 @@
#!/bin/sh
if [ -f "$__object/parameter/name" ]; then
name="(cat "$__object/parameter/name")"
else
name="$__object_id"
echo "$name" > "$__object/parameter/name"
fi

@ -0,0 +1,4 @@
#!/bin/sh
__planet Saturn
require="__planet/Saturn" __moon Prometheus --planet Saturn
Loading…
Cancel
Save