コード例 #1
0
ファイル: test_classifier.py プロジェクト: 522986491/sfc
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')
コード例 #2
0
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')
コード例 #3
0
ファイル: test_classifier.py プロジェクト: 522986491/sfc
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
コード例 #4
0
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