tests for update
diff --git a/xos/tosca/tests/basetest.py b/xos/tosca/tests/basetest.py
index 8082f8c..0b5a19d 100644
--- a/xos/tosca/tests/basetest.py
+++ b/xos/tosca/tests/basetest.py
@@ -50,7 +50,9 @@
obj = cls.objects.get(name=name)
assert(obj)
for (k,v) in kwargs.items():
- assert(getattr(obj,k) == v)
+ 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)
def try_to_delete(self, cls, **kwargs):
objs = cls.objects.filter(**kwargs)
diff --git a/xos/tosca/tests/servicetest.py b/xos/tosca/tests/servicetest.py
index e493461..023c441 100644
--- a/xos/tosca/tests/servicetest.py
+++ b/xos/tosca/tests/servicetest.py
@@ -6,7 +6,8 @@
tests = ["create_service_minimal",
"create_service_notpublished",
"create_service_notenabled",
- "create_service_public_key"]
+ "create_service_public_key",
+ "update_service_notpublished"]
def cleanup(self):
self.try_to_delete(Service, name="test_svc")
@@ -31,6 +32,15 @@
self.execute(self.make_nodetemplate("test_svc", "tosca.nodes.Service", {"public_key": "foobar"}))
self.assert_obj(Service, "test_svc", kind="generic", published=True, enabled=True, public_key="foobar")
+ 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
+ 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)
+
if __name__ == "__main__":
ServiceTest()