add maximal service test, support reqs in create_node_template, cleanup debuggin
diff --git a/xos/tosca/engine.py b/xos/tosca/engine.py
index fc1f10f..3a4aeb2 100644
--- a/xos/tosca/engine.py
+++ b/xos/tosca/engine.py
@@ -44,7 +44,7 @@
self.ordered_nodetemplates = []
self.ordered_names = self.topsort_dependencies()
- print "ordered_names", self.ordered_names
+ self.log("ordered_names: %s" % self.ordered_names)
for name in self.ordered_names:
if name in self.nodetemplates_by_name:
self.ordered_nodetemplates.append(self.nodetemplates_by_name[name])
diff --git a/xos/tosca/tests/basetest.py b/xos/tosca/tests/basetest.py
index 0b5a19d..038eea2 100644
--- a/xos/tosca/tests/basetest.py
+++ b/xos/tosca/tests/basetest.py
@@ -40,6 +40,16 @@
yml = yml + " properties:\n"
for (k,v) in props.items():
yml = yml + " %s: %s\n" % (k, v)
+
+ if reqs:
+ yml = yml + " requirements:\n"
+ i=0
+ for (name,relat) in reqs:
+ yml = yml + " - req%d:\n" % i
+ yml = yml + " node: %s\n" % name
+ yml = yml + " relationship: %s\n" % relat
+ i = i + 1
+
return yml
def assert_noobj(self, cls, name):
@@ -53,6 +63,7 @@
if (getattr(obj,k,None) != v):
print "Object %s property '%s' is '%s' and should be '%s'" % (obj, k, getattr(obj,k,None), v)
assert(False)
+ return obj
def try_to_delete(self, cls, **kwargs):
objs = cls.objects.filter(**kwargs)
@@ -64,7 +75,7 @@
#print self.base_yaml+yml
- xt = XOSTosca(self.base_yaml+yml, parent_dir=parentdir, log_to_console=True)
+ xt = XOSTosca(self.base_yaml+yml, parent_dir=parentdir, log_to_console=False)
xt.execute(u)
def runtest(self):
diff --git a/xos/tosca/tests/servicetest.py b/xos/tosca/tests/servicetest.py
index 023c441..585e143 100644
--- a/xos/tosca/tests/servicetest.py
+++ b/xos/tosca/tests/servicetest.py
@@ -35,11 +35,29 @@
def update_service_notpublished(self):
self.assert_noobj(Service, "test_svc")
self.execute(self.make_nodetemplate("test_svc", "tosca.nodes.Service"))
- self.assert_obj(Service, "test_svc", kind="generic", published=True, enabled=True)
- original_id = Service.objects.get(name="test_svc").id
+ original_obj = self.assert_obj(Service, "test_svc", kind="generic", published=True, enabled=True)
self.execute(self.make_nodetemplate("test_svc", "tosca.nodes.Service", {"published": False}))
- self.assert_obj(Service, "test_svc", kind="generic", published=False, enabled=True)
- assert(Service.objects.get(name="test_svc").id == original_id)
+ updated_obj = self.assert_obj(Service, "test_svc", kind="generic", published=False, enabled=True)
+ assert(original_obj.id == updated_obj.id)
+
+ def create_service_maximal(self):
+ self.assert_noobj(Service, "test_svc")
+ self.execute(self.make_nodetemplate("test_svc", "tosca.nodes.Service",
+ {"kind": "testkind",
+ "published": False,
+ "enabled": False,
+ "view_url": "http://foo/",
+ "icon_url": "http://bar/",
+ "public_key": "foobar",
+ "versionNumber": "1.2"} ))
+ self.assert_obj(Service, "test_svc",
+ kind="testkind",
+ published=False,
+ enabled=False,
+ view_url="http://foo/",
+ icon_url="http://bar/",
+ public_key="foobar",
+ versionNumber="1.2")
if __name__ == "__main__":
ServiceTest()