base test cases for Node, Site, and Deployment
diff --git a/xos/tosca/tests/alltests.py b/xos/tosca/tests/alltests.py
index 59ad49d..04c4ade 100644
--- a/xos/tosca/tests/alltests.py
+++ b/xos/tosca/tests/alltests.py
@@ -4,8 +4,14 @@
from servicetest import ServiceTest
from usertest import UserTest
from computetest import ComputeTest
+from sitetest import SiteTest
+from deploymenttest import DeploymentTest
+from nodetest import NodeTest
if __name__ == "__main__":
+ SiteTest()
+ DeploymentTest()
+ NodeTest()
NetworkTest()
PortTest()
CoarseTenancyTest()
diff --git a/xos/tosca/tests/deploymenttest.py b/xos/tosca/tests/deploymenttest.py
new file mode 100644
index 0000000..188ead2
--- /dev/null
+++ b/xos/tosca/tests/deploymenttest.py
@@ -0,0 +1,28 @@
+from basetest import BaseToscaTest
+
+from core.models import Deployment
+
+class DeploymentTest(BaseToscaTest):
+ tests = ["create_deployment_minimal",
+ "destroy_deployment",
+ ]
+
+ def cleanup(self):
+ self.try_to_delete(Deployment, name="testdep")
+
+ def create_deployment_minimal(self):
+ self.assert_noobj(Deployment, "testdep")
+ self.execute(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ instance = self.assert_obj(Deployment, "testdep")
+
+ def destroy_deployment(self):
+ self.assert_noobj(Deployment, "testdep")
+ self.execute(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ instance = self.assert_obj(Deployment, "testdep")
+ self.destroy(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ self.assert_noobj(Deployment, "testdep")
+
+if __name__ == "__main__":
+ DeploymentTest()
+
+
diff --git a/xos/tosca/tests/nodetest.py b/xos/tosca/tests/nodetest.py
new file mode 100644
index 0000000..dad2ab0
--- /dev/null
+++ b/xos/tosca/tests/nodetest.py
@@ -0,0 +1,62 @@
+from basetest import BaseToscaTest
+
+from core.models import Node, Site, Deployment, SiteDeployment
+
+class NodeTest(BaseToscaTest):
+ tests = ["create_node_minimal",
+ "destroy_node",
+ ]
+
+ def cleanup(self):
+ self.try_to_delete(Node, name="testnode")
+ self.try_to_delete(Site, name="testsite")
+ self.try_to_delete(Deployment, name="testdep")
+
+ def get_base_templates(self):
+ return \
+"""
+ testdep:
+ type: tosca.nodes.Deployment
+ testcon:
+ type: tosca.nodes.Controller
+ requirements:
+ - deployment:
+ node: testdep
+ relationship: tosca.relationships.ControllerDeployment
+ testsite:
+ type: tosca.nodes.Site
+ requirements:
+ - deployment:
+ node: testdep
+ relationship: tosca.relationships.SiteDeployment
+ requirements:
+ - controller:
+ node: testcon
+ relationship: tosca.relationships.UsesController
+"""
+
+ def create_node_minimal(self):
+ self.assert_noobj(Node, "testnode")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testnode", "tosca.nodes.Node",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+ ("testdep", "tosca.relationships.MemberOfDeployment")]))
+ self.assert_obj(Node, "testnode")
+
+ def destroy_node(self):
+ self.assert_noobj(Node, "testnode")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testnode", "tosca.nodes.Node",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+ ("testdep", "tosca.relationships.MemberOfDeployment")]))
+ self.assert_obj(Node, "testnode")
+ self.destroy(self.get_base_templates() +
+ self.make_nodetemplate("testnode", "tosca.nodes.Node",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+ ("testdep", "tosca.relationships.MemberOfDeployment")]))
+ self.assert_noobj(Node, "testnode")
+
+if __name__ == "__main__":
+ NodeTest()
+
+
diff --git a/xos/tosca/tests/sitetest.py b/xos/tosca/tests/sitetest.py
new file mode 100644
index 0000000..50a9ea0
--- /dev/null
+++ b/xos/tosca/tests/sitetest.py
@@ -0,0 +1,28 @@
+from basetest import BaseToscaTest
+
+from core.models import Site
+
+class SiteTest(BaseToscaTest):
+ tests = ["create_site_minimal",
+ "destroy_site",
+ ]
+
+ def cleanup(self):
+ self.try_to_delete(Site, name="testsite")
+
+ def create_site_minimal(self):
+ self.assert_noobj(Site, "testsite")
+ self.execute(self.make_nodetemplate("testsite", "tosca.nodes.Site"))
+ instance = self.assert_obj(Site, "testsite")
+
+ def destroy_site(self):
+ self.assert_noobj(Site, "testsite")
+ self.execute(self.make_nodetemplate("testsite", "tosca.nodes.Site"))
+ instance = self.assert_obj(Site, "testsite")
+ self.destroy(self.make_nodetemplate("testsite", "tosca.nodes.Site"))
+ self.assert_noobj(Site, "testsite")
+
+if __name__ == "__main__":
+ SiteTest()
+
+