Permalink
Browse files

tests for getAllWorkflows

use macros for basic types in xml
  • Loading branch information...
1 parent c29ab12 commit a9c75c5735808e736d3c446326fddb2ab2cfd52a @sigma sigma committed Nov 2, 2010
View
@@ -451,6 +451,8 @@ def __init__(self, server, holder):
self.attributes = self.__convertAttributes(holder._attributes)
def __convertAttributes(self, attrs):
+ if attrs is None:
+ return []
return [WorkflowAttribute(self._server, it) for it in attrs._item]
def execute(self, inputs={}):
@@ -0,0 +1,33 @@
+from mock_transports import TransportFactory
+from base import TestCase
+import sys
+
+from vmw.vco.client import Client, Workflow
+
+_fake_url = "http://vco.example.com/vmware-vmo-webcontrol/webservice"
+_operation = "getAllWorkflows"
+
+class TestGetAllWorkflows(TestCase):
+
+ def setUp(self):
+ self._transport = TransportFactory()
+ self._client = Client(_fake_url,
+ username="foo", password="bar",
+ transport=self._transport)
+
+ def _testWorkflowsBase(self, params):
+ self._transport.recordTransaction(_operation,
+ response_params = params)
+
+ wfs = self._client.getAllWorkflows()
+ self.assertTrue(isinstance(wfs, list))
+ for wf in wfs:
+ self.assertTrue(isinstance(wf, Workflow))
+
+ def testNoWorkflow(self):
+ _params = {'workflows': []}
+ self._testWorkflowsBase(_params)
+
+ def testSingleWorkflow(self):
+ _params = {'workflows': [{'name': "Plop"}]}
+ self._testWorkflowsBase(_params)
@@ -1,20 +1,10 @@
+{% import "types.xml" as types %}
{% extends "base.xml" %}
{% block body %}
<vco:getAllPluginsResponse>
{% for p in plugins %}
<vco:getAllPluginsReturn>
- {% if p.name is defined %}
- <moduleName>{{ p.name }}</moduleName>
- {% endif %}
- {% if p.version is defined %}
- <moduleVersion>{{ p.version }}</moduleVersion>
- {% endif %}
- {% if p.desc is defined %}
- <moduleDescription>{{ p.desc }}</moduleDescription>
- {% endif %}
- {% if p.display is defined %}
- <moduleDisplayName>{{ p.display }}</moduleDisplayName>
- {% endif %}
+ {{ types.Plugin(p) }}
</vco:getAllPluginsReturn>
{% endfor %}
</vco:getAllPluginsResponse>
@@ -0,0 +1,15 @@
+{% import "types.xml" as types %}
+{% extends "base.xml" %}
+{% block body %}
+<vco:getAllWorkflowsResponse>
+ {% for wf in workflows %}
+ <vco:getAllWorkflowsReturn>
+ {{ types.Workflow(wf) }}
+ </vco:getAllWorkflowsReturn>
+ {% endfor %}
+</vco:getAllWorkflowsResponse>
+{% endblock %}
+
+{# Local Variables: #}
+{# mode: django-html-mumamo #}
+{# End: #}
@@ -0,0 +1,54 @@
+{% macro Plugin(p) %}
+ {% if p.name is defined %}
+ <moduleName>{{ p.name }}</moduleName>
+ {% endif %}
+ {% if p.version is defined %}
+ <moduleVersion>{{ p.version }}</moduleVersion>
+ {% endif %}
+ {% if p.desc is defined %}
+ <moduleDescription>{{ p.desc }}</moduleDescription>
+ {% endif %}
+ {% if p.display is defined %}
+ <moduleDisplayName>{{ p.display }}</moduleDisplayName>
+ {% endif %}
+{% endmacro %}
+
+{% macro Parameter(p) %}
+ {% if p.name is defined %}
+ <name>{{ p.name }}</name>
+ {% endif %}
+ {% if p.type is defined %}
+ <type>{{ p.type }}</type>
+ {% endif %}
+{% endmacro %}
+
+{% macro Parameters(params) %}
+ {% for p in params %}
+ {{ Parameter(p) }}
+ {% endfor %}
+{% endmacro %}
+
+{% macro Workflow(wf) %}
+ {% if wf.name is defined %}
+ <name>{{ wf.name }}</name>
+ {% endif %}
+ {% if wf.id is defined %}
+ <id>{{ wf.id }}</id>
+ {% endif %}
+ {% if wf.description is defined %}
+ <description>{{ wf.description }}</description>
+ {% endif %}
+ {% if wf.input is defined %}
+ <inParameters>{{ Parameters(wf.input) }}</inParameters>
+ {% endif %}
+ {% if wf.output is defined %}
+ <outParameters>{{ Parameters(wf.output) }}</outParameters>
+ {% endif %}
+ {% if wf.attributes is defined %}
+ <attributes>{{ Parameters(wf.attributes) }}</attributes>
+ {% endif %}
+{% endmacro %}
+
+{# Local Variables: #}
+{# mode: django-html-mumamo #}
+{# End: #}

0 comments on commit a9c75c5

Please sign in to comment.