WEBSERVICE_URL = "https://my3s18krif.execute-api.us-east-1.amazonaws.com" import requests from faker import Faker fake = Faker() n = 3 outs = [] outs2 = [] OK = True for i in range(n): try: outs.append(requests.post(WEBSERVICE_URL, json={'userId': 1, 'title': fake.catch_phrase(), 'body': fake.text()}).json()) except: print("Nie udało się dodać nowego zasobu") OK = False for i in range(n): try: tmp = requests.get(WEBSERVICE_URL+'/'+str(outs[i]['id'])).json() if tmp != outs[i]: print("Pobrany zasób nie jest zgodny ze wzrocem") OK = False except: print("Nie udało się pobrać zasobu: "+WEBSERVICE_URL+'/'+str(outs[i]['id'])) OK = False for i in range(n): try: outs2.append(requests.put(WEBSERVICE_URL+'/'+str(outs[i]['id']), json={'userId': 1, 'title': fake.catch_phrase(), 'body': fake.text()}).json()) except: OK = False print("Nie udało się zmodyfikować zasobu: "+WEBSERVICE_URL+'/'+str(outs[i]['id'])) for i in range(n): try: tmp = requests.get(WEBSERVICE_URL+'/'+str(outs[i]['id'])).json() if tmp != outs2[i]: print("Pobrany zasób nie jest zgodny ze zaktualizowanym wzrocem") OK = False except: print("Nie udało się pobrać zasobu: "+WEBSERVICE_URL+'/'+str(outs[i]['id'])) OK = False for i in range(n): try: requests.delete(WEBSERVICE_URL+'/'+str(outs[i]['id']), json={'userId': 1, 'title': fake.catch_phrase(), 'body': fake.text()}).json() except Exception as e: print(e) print("Nie udało się usunąć zasobu: "+WEBSERVICE_URL+'/'+str(outs[i]['id'])) OK = False if OK: print("==================\nOK zaliczone") else: print("==================\nNie zaliczone")