def testpost(self): lib = PycURLLibrary() messageFile = join(testenv.ROOT_DIR, 'soap-request.xml') print(messageFile) f = open(messageFile, 'r') data = f.read() f.close() lib.verbose() lib.set_url('http://localhost:53004/soap') lib.post_fields(data) lib.perform() response = lib.response() if response is None: raise NotImplementedError print('POST Response:') print(response) responseHeader = lib.response_headers() print('POST Response Headers:') print(responseHeader) responseStatus = lib.http_response_status() print('HTTP Response Status:') print(responseStatus) lib.response_status_should_contain(unicode('200')) root = lib.parse_xml() print(root) root = lib.xml_root_element() print(root) elems = lib.find_elements(root, unicode('country')) print(elems) if not elems: print('country empty') elems = lib.find_elements( root, unicode('.//{http://ws.poc.jivalo/hello/v1}customer')) if not elems: print('customer empty') print elems for el in elems: print(el.tag) elems = lib.find_elements(root, unicode('.//name')) lib.should_contain_element(root, unicode('.//name')) print(elems) for el in elems: print(el.tag) print(el.text) lib.element_should_contain(elems[0], unicode('Hello, world!')) elem = lib.find_first_element(root, unicode('.//name')) print(elem) try: lib.element_should_contain(elems[0], 'Hello') except AssertionError as a: print(a) try: lib.should_contain_element(root, './country') except AssertionError as a: print(a) pass
def testget(self): lib = PycURLLibrary() lib.verbose() lib.add_header('Content-Type: text/xml; charset=UTF-8') lib.add_header('Version: 1') lib.set_url('http://localhost:53004/rest') lib.perform() response = lib.response() if response is None: raise NotImplementedError print('GET Response:') print(response) responseHeader = lib.response_headers() print('GET Response Headers:') print(responseHeader) pass
def testgetHeaderFile(self): lib = PycURLLibrary() lib.verbose() headerFile = join(testenv.ROOT_DIR, 'headers-file.txt') lib.headers_file(headerFile) lib.set_url('http://localhost:53004/rest') lib.perform() response = lib.response() if response is None: raise NotImplementedError print('GET Response:') print(response) responseHeader = lib.response_headers() print('GET Response Headers:') print(responseHeader) pass
def testSetterStyleKeywords(self): lib = PycURLLibrary() lib.verbose() lib.insecure_ssl() lib.request_method('GET') lib.add_header('Content-Type: text/xml; charset=UTF-8') lib.add_header('Version: 1') lib.set_url('http://localhost:53004/rest') lib.ca_path('/tmp') lib.client_certificate_file('cert.pem') lib.private_key_file('key.pem') lib.post_fields('testing') postFieldsFile = join(testenv.ROOT_DIR, 'soap-request.xml') lib.post_fields_file(postFieldsFile) lib.server_connection_establishment_timeout('30') pass
def testpost(self): lib = PycURLLibrary(); messageFile = join(testenv.ROOT_DIR, 'soap-request.xml') print messageFile f = open(messageFile, 'r') data = f.read() f.close() lib.verbose() lib.set_url('http://localhost:53004/soap') lib.post_fields(data) lib.perform() response = lib.response() if response is None: raise NotImplementedError print 'POST Response:' print response responseHeader = lib.response_headers() print 'POST Response Headers:' print responseHeader responseStatus = lib.http_response_status() print 'HTTP Response Status:' print responseStatus lib.response_status_should_contain(unicode('200')) root = lib.parse_xml() print root root = lib.xml_root_element() print root elems = lib.find_elements(root, unicode('country')) print elems if not elems: print 'country empty' elems = lib.find_elements(root, unicode('.//{http://ws.poc.jivalo/hello/v1}customer')) if not elems: print 'customer empty' print elems for el in elems: print el.tag elems = lib.find_elements(root, unicode('.//name')) lib.should_contain_element(root, unicode('.//name')) print elems for el in elems: print el.tag print el.text lib.element_should_contain(elems[0], unicode('Hello, world!')) elem = lib.find_first_element(root, unicode('.//name')) print elem try: lib.element_should_contain(elems[0], 'Hello') except AssertionError, a: print a
def testgetHeaderFile(self): lib = PycURLLibrary(); lib.verbose() headerFile = join(testenv.ROOT_DIR, 'headers-file.txt') lib.headers_file(headerFile) lib.set_url('http://localhost:53004/rest') lib.perform() response = lib.response() if response is None: raise NotImplementedError print 'GET Response:' print response responseHeader = lib.response_headers() print 'GET Response Headers:' print responseHeader pass
def testget(self): lib = PycURLLibrary(); lib.verbose() lib.add_header('Content-Type: text/xml; charset=UTF-8') lib.add_header('Version: 1') lib.set_url('http://localhost:53004/rest') lib.perform() response = lib.response() if response is None: raise NotImplementedError print 'GET Response:' print response responseHeader = lib.response_headers() print 'GET Response Headers:' print responseHeader pass
def testSetterStyleKeywords(self): lib = PycURLLibrary(); lib.verbose() lib.insecure_ssl() lib.request_method('GET') lib.add_header('Content-Type: text/xml; charset=UTF-8') lib.add_header('Version: 1') lib.set_url('http://localhost:53004/rest') lib.ca_path('/tmp') lib.client_certificate_file('cert.pem') lib.private_key_file('key.pem') lib.post_fields('testing') postFieldsFile = join(testenv.ROOT_DIR, 'soap-request.xml') lib.post_fields_file(postFieldsFile) lib.server_connection_establishment_timeout('30') pass