class TestEcho(TestCase): def setUp(self): self._transport = TransportFactory() self._client = Client(_fake_url, transport=self._transport) def _testEchoBase(self, msg): self._transport.recordTransaction(_echo_operation, request_checker = lambda req: req._message == msg, response_params = {'message': xml_escape(msg)}) resp = self._client.echo(msg) self.assertEqual(resp, msg) def testEcho(self): self._testEchoBase("plop") def testEchoEmpty(self): self._testEchoBase("") def testEchoLong(self): self._testEchoBase("repeated pattern"*50) def testEchoXml(self): self._testEchoBase("<foo/><bar>baz</bar>")
class TestGetAllPlugins(TestCase): def setUp(self): self._transport = TransportFactory() self._client = Client(_fake_url, username="******", password="******", transport=self._transport) def _testPluginBase(self, params): self._transport.recordTransaction(_operation, response_params=params) plugs = self._client.getAllPlugins() self.assertTrue(isinstance(plugs, list)) for p in plugs: self.assertTrue(isinstance(p, Plugin)) return plugs def testBasicPlugin(self): _params = { 'plugins': [{ 'name': 'plop', 'version': '0.1', 'desc': 'plop plug-in', 'display': 'Plop' }] } self._testPluginBase(_params) def testEmptyPlugin(self): _params = {'plugins': [{}]} self._testPluginBase(_params) def testNoPlugin(self): _params = {} self._testPluginBase(_params) def testIncompletePlugins(self): _params = { 'plugins': [{ 'version': '0.1', 'desc': 'plop plug-in', 'display': 'Plop' }, { 'name': 'plop', 'desc': 'plop plug-in', 'display': 'Plop' }, { 'name': 'plop', 'version': '0.1', 'display': 'Plop' }, { 'name': 'plop', 'version': '0.1', 'desc': 'plop plug-in' }] } self._testPluginBase(_params)
class TestGetAllPlugins(TestCase): def setUp(self): self._transport = TransportFactory() self._client = Client(_fake_url, username="******", password="******", transport=self._transport) def _testPluginBase(self, params): self._transport.recordTransaction(_operation, response_params = params) plugs = self._client.getAllPlugins() self.assertTrue(isinstance(plugs, list)) for p in plugs: self.assertTrue(isinstance(p, Plugin)) return plugs def testBasicPlugin(self): _params = {'plugins': [{'name': 'plop', 'version': '0.1', 'desc': 'plop plug-in', 'display': 'Plop'}]} self._testPluginBase(_params) def testEmptyPlugin(self): _params = {'plugins': [{}]} self._testPluginBase(_params) def testNoPlugin(self): _params = {} self._testPluginBase(_params) def testIncompletePlugins(self): _params = {'plugins': [{'version': '0.1', 'desc': 'plop plug-in', 'display': 'Plop'}, {'name': 'plop', 'desc': 'plop plug-in', 'display': 'Plop'}, {'name': 'plop', 'version': '0.1', 'display': 'Plop'}, {'name': 'plop', 'version': '0.1', 'desc': 'plop plug-in'}]} self._testPluginBase(_params)
class TestGetAllWorkflows(TestCase): def setUp(self): self._transport = TransportFactory() self._client = Client(_fake_url, username="******", password="******", 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)) return wfs def _compareWorkflow(self, wf, wf_def): self.assertEquals(wf_def['name'], wf.name) self.assertEquals(wf_def['description'], wf.description) self.assertEquals(wf_def['id'], wf.id) def testNoWorkflow(self): _params = {'workflows': []} self._testWorkflowsBase(_params) def testMinimalWorkflow(self): _params = {'workflows': [{'name': "Plop"}]} wfs = self._testWorkflowsBase(_params) self.assertEquals(len(wfs), 1) self.assertEquals(wfs[0].name, "Plop") def testCompleteWorkflow(self): wf0 = {'name': "Plop", 'description': "dummy workflow", 'id': "12345-67890", 'input': [{'name': "in1", 'type': "type1"}], 'output': [{'name': "out1", 'type': "type1"}], 'attributes': [{'name': "attr1", 'type': "type1"}]} _params = {'workflows': [wf0]} wfs = self._testWorkflowsBase(_params) self.assertEquals(len(wfs), 1) self._compareWorkflow(wfs[0], wf0)
def setUp(self): self._transport = TransportFactory() self._client = Client(_fake_url, username="******", password="******", transport=self._transport)
def setUp(self): self._transport = TransportFactory() self._client = Client(_fake_url, transport=self._transport)