result = c.send_task( name='sudo_plugin.sudo.run', kwargs=kwargs, queue=agent_config['name']) self.assertRaises(Exception, result.get, timeout=10) ctx = get_local_context() agent_config = {'disable_requiretty': True} tasks.install(ctx, cloudify_agent=agent_config) tasks.start(ctx) self.assert_installed_plugins(ctx, agent_config['name']) broker_url = 'amqp://*****:*****@localhost:5672//' c = Celery(broker=broker_url, backend=broker_url) kwargs = {'command': 'ls -l'} result = c.send_task( name='sudo_plugin.sudo.run', kwargs=kwargs, queue=agent_config['name']) result.get(timeout=10) def test_download_resource_on_host(self): ctx = get_local_context() runner = FabricRunner(ctx) tasks.download_resource_on_host( ctx.logger, runner, AGENT_PACKAGE_URL, 'Ubuntu-agent.tar.gz') r = runner.exists('Ubuntu-agent.tar.gz') self.assertTrue(r) if __name__ == '__main__': testtools.main()
'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'HTTP_X_H_Test': 'Foobar', 'HTTP_CONTENT_TYPE': 'application/x-www-form-urlencoded', 'QUERY_STRING': querystring, 'HTTP_HOST': 'foobar.baz:8080', 'SERVER_NAME': 'foobar.baz', 'HTTP_FOO': 'bar', 'SCRIPT_NAME': '/some/script/dir', 'REQUEST_METHOD': method } resp = Response() def start_response(status, headers, exc_info_=None): resp.status = status resp.headers = dict(headers) global exc_info exc_info = exc_info_ body = app(fake_env, start_response) if exc_info: raise exc_info[0](exc_info[1]) # No traceback because python3 body = body[0] return resp, body.decode('utf-8') if __name__ == '__main__': unittest.main()
exc = err self.assertEquals(contents.seeks, [0]) self.assertEquals(str(exc), 'oops') contents = LocalContents(tell_value=123) exc = None try: conn.put_object('c', 'o', contents) except socket.error, err: exc = err self.assertEquals(contents.seeks, [123]) self.assertEquals(str(exc), 'oops') contents = LocalContents() contents.tell = None exc = None try: conn.put_object('c', 'o', contents) except c.ClientException, err: exc = err self.assertEquals(contents.seeks, []) self.assertEquals( str(exc), "put_object('c', 'o', ...) failure " "and no ability to reset contents for reupload.") finally: c.http_connection = orig_conn if __name__ == '__main__': testtools.main()
def test_select(self): dom = self._load_sample_query_data_set() res = dom.select("select * from mydomain where Title = 'The Right Stuff'") for row in res: print row class FakeBackedBotoTests(_BotoTests, unittest.TestCase): @classmethod def setUpClass(cls): super(FakeBackedBotoTests, cls).setUpClass() basicdb.load_backend('fake') class _FilesystemBackedBotoTests(_BotoTests): @classmethod def setUpClass(cls): super(_FilesystemBackedBotoTests, cls).setUpClass() basicdb.load_backend('filesystem') class _RiakBackedBotoTests(_BotoTests): @classmethod def setUpClass(cls): super(_RiakBackedBotoTests, cls).setUpClass() basicdb.load_backend('riak') if __name__ == "__main__": unittest.main()