Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import time
  2.  
  3. from constants import *
  4. from colorama import Fore
  5. from xml.dom.minidom import parseString
  6. from http.client import HTTPSConnection as conn
  7.  
  8. def request_data(connection, url, method, payload):
  9.     connection.request(method, url, payload, headers)
  10.     decode = connection.getresponse().read().decode('utf-8')
  11.     return parseString(decode).toprettyxml()
  12.  
  13. start = time.time()
  14. endpoint = '/endpoint'
  15. method = 'POST'
  16.  
  17. pcf_connection = conn('service-1.com')
  18. mule_connection = conn('service-2.com')
  19.  
  20. for i in payload:
  21.     pcf = request_data(pcf_connection, endpoint, method)
  22.     mule = request_data(mule_connection, endpoint, method)
  23.  
  24.     if pcf != mule:
  25.         print('descrepancy found:')
  26.  
  27.         for i, k in zip(pcf.splitlines(), mule.splitlines()):
  28.             if i != k:
  29.                 print(Fore.GREEN + i)
  30.                 print(Fore.RED + k)
  31.  
  32. pcf_connection.close()
  33. mule_connection.close()
  34.  
  35. print(Fore.WHITE + 'done. time: ', round(time.time() - start, 2), 's', sep='')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement