def produce_rsp(): """ Fixture - create RSP in ODL """ session = requests.Session() headers = {'content-type': 'application/json'} try: for url in (SF_URL, SFF_URL, SFC_URL, SFP_URL, RSP_RPC_URL): sleep(0.1) test_data = url_2_json_data[url] test_file_path = TEST_FILES_COMMON[test_data['file']] test_file_data = read_json(test_file_path, output=str) http_method = getattr(session, test_data['method']) response = http_method(url=url, stream=False, headers=headers, data=test_file_data, auth=sfc_globals.odl_credentials) if not response.ok: raise except: pytest.fail('Failed to create RSP')
def produce_rsp(): """ Fixture - create RSP in ODL """ session = requests.Session() headers = {'content-type': 'application/json'} try: for url in (SF_URL, SFF_URL, SFC_URL, SFP_URL, RSP_RPC_URL): sleep(0.1) test_data = url_2_json_data[url] test_file_path = TEST_FILES_COMMON[test_data['file']] test_file_data = read_json(test_file_path, output=str) http_method = getattr(session, test_data['method']) response = http_method(url=url, stream=False, headers=headers, data=test_file_data, auth=sfc_globals.odl_credentials) if not response.ok: raise except Exception: pytest.fail('Failed to create RSP')
def acl_data(request, acl_test_files): """Fixture - load ACL JSON to dict :param request: test function :type request: `:class:_pytest.python.SubRequest` :param acl_test_files: virl_test_files fixture :type acl_test_files: dict :returns dict """ acl_name = request.getfuncargvalue('acl_json') try: acl_file_path = acl_test_files[acl_name] except KeyError: pytest.fail('Test file "data/%s.json" does not exist' % acl_name) acl_data = read_json(acl_file_path) return acl_data