コード例 #1
0
def test_arbitrator_statusType_case():

    # Create the CLOB Parser object
    clob_parser = module_clob_parser.CLOBParser()

    # Get the test data object
    clob_object = create_clob_data_object()

    # Set parent and keyword for the parse operation
    search_parent = 'arbitrator'
    search_key = 'statusType'

    # Execute the parse operation
    result_list = clob_parser.parse(clob_object, search_parent, search_key)

    print('*********************************************')
    print('Inside: test_arbitrator_profileUuid_case() - 1')
    print('result_list length: ', len(result_list))


    # Validation
    result = result_list[0]
    assert len(result_list) == 1
    assert result.get_parent() == 'arbitrator'
    assert result.get_key() == 'statusType'
    assert result.get_value() == 'A'
コード例 #2
0
def test_phone_case():

    # Create the CLOB Parser object
    clob_parser = module_clob_parser.CLOBParser()

    # Get the test data object
    clob_object = create_clob_data_object()

    # Set parent and keyword for the parse operation
    search_parent = 'phone'
    search_key = ''

    # Execute the parse operation
    result_list = clob_parser.parse(clob_object, search_parent, search_key)

    print('*********************************************')
    print('Inside: test_arbitrator_profileUuid_case() - 3')
    print('result_list length: ', len(result_list))

    # Validation
    result = result_list[0]
    assert len(result_list) == 3
    assert result.get_parent() == 'phone'
    assert result.get_key() == 'id'
    assert result.get_value() == '1'

    result = result_list[1]
    assert result.get_parent() == 'phone'
    assert result.get_key() == 'phoneNumber'
    assert result.get_value() == '(605) 336-2880'

    result = result_list[2]
    assert result.get_parent() == 'phone'
    assert result.get_key() == 'isInherited'
    assert result.get_value() == 'Y'
コード例 #3
0
def test_education_case():

    # Create the CLOB Parser object
    clob_parser = module_clob_parser.CLOBParser()

    # Get the test data object
    clob_object = create_clob_data_object()

    # Set parent and keyword for the parse operation
    search_parent = 'education'
    search_key = ''

    # Execute the parse operation
    result_list = clob_parser.parse(clob_object, search_parent, search_key)

    print('*********************************************')
    print('Inside: test_arbitrator_profileUuid_case() - 9')
    print('result_list length: ', len(result_list))

    # Validation
    # Collection
    result = result_list[0]
    assert len(result_list) == 9
    assert result.get_parent() == 'education'
    assert result.get_key() == 'type'
    assert result.get_value() == 'LE'

    result = result_list[1]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'schoolName'
    assert result.get_value() == 'Nicholaus Copernicus'

    result = result_list[2]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'graduationDate'
    assert result.get_value() == '1952'

    # Collection
    result = result_list[3]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'type'
    assert result.get_value() == 'LW'

    result = result_list[4]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'schoolName'
    assert result.get_value() == 'Happy LAw School'

    result = result_list[5]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'graduationDate'
    assert result.get_value() == '1991'

    # Collection
    result = result_list[6]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'type'
    assert result.get_value() == 'LQ'

    result = result_list[7]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'schoolName'
    assert result.get_value() == 'Law School Number 1'

    result = result_list[8]
    assert result.get_parent() == 'education'
    assert result.get_key() == 'graduationDate'
    assert result.get_value() == '1911'
コード例 #4
0
    def run6(self):
        logging.debug('------------------------------------------------------------')
        logging.debug('Inside: ParseDictionary::run6()')
        logging.debug("Loading the data file")



        # Phone Data
        phone01 = OrderedDict([('id', '1'), ('phoneNumber', '(605) 336-2880'), ('isInherited', 'Y')])
        phones = OrderedDict([('phone', phone01)])

        # Email Data
        email01 = OrderedDict([('id', '1'), ('address', '*****@*****.**'), ('isInherited', 'Y')])
        emails = OrderedDict([('email', email01)])

        # Alternate (phones)
        # Alternate Phone Data
        alt_phone01 = OrderedDict([('id', '99'), ('phoneNumber', '(999) 888-2222'), ('isInherited', 'Y')])
        alt_phones = OrderedDict([('phone', alt_phone01)])

        # Alternate Container
        alternate = OrderedDict([('phones', alt_phones)])

        # Education data
        education01 = OrderedDict([('type', 'LE'), ('schoolName', 'Nicholaus Copernicus'), ('graduationDate', '1952')])
        education02 = OrderedDict([('type', 'LW'), ('schoolName', 'Happy LAw School'), ('graduationDate', '1991')])
        education03 = OrderedDict([('type', 'LQ'), ('schoolName', 'Law School Number 1'), ('graduationDate', '1911')])
        educations = OrderedDict([('education', [education01, education02, education03   ]   )])

        allOracle88 = OrderedDict([('arbitrator', OrderedDict([('profileUuid', 'Iaac53e00bd9a11de9b8c850332338889'),
                                                               ('phones', phones),
                                                               ('alternate', alternate),
                                                               ('emails', emails),
                                                               ('educations', educations),
                                                               ('statusType', 'A') ])  )])

        print(json.dumps(allOracle88, indent=2))

        # Note - we might want to use recussion to iterationt his stuff
        # We are fun playing here

        logging.debug("Start parsing ... ")

        clob_parser = module_clob_parser.CLOBParser()

        # search_parent - is required. When found it will return all the children
        # search_keyword - will return a specific child

        # Test Case 1.0 - Pass
        parse_context10 = OrderedDict([('parent', 'arbitrator'),
                                     ('child', 'profileUuid'),
                                     ('subChild', ''),
                                     ('subSubChild', '')])

        # Test Case 1.1 - Pass
        parse_context11 = OrderedDict([('parent', 'arbitrator'),
                                     ('child', 'statusType'),
                                     ('subChild', ''),
                                     ('subSubChild', '')])

        # Test Case 2.0 - pass
        parse_context20 = OrderedDict([('parent', 'arbitrator'),
                                     ('child', 'phones'),
                                     ('subChild', 'phone'),
                                     ('subSubChild', '')])

        # Test Case 2.1 - pass
        parse_context21 = OrderedDict([('parent', 'arbitrator'),
                                     ('child', 'phones'),
                                     ('subChild', 'phone'),
                                     ('subSubChild', 'id')])

        # Test Case 3.0 - pass
        parse_context30 = OrderedDict([('parent', 'arbitrator'),
                                     ('child', 'educations'),
                                     ('subChild', 'education'),
                                     ('subSubChild', '')])

        # Test Case 9.0 - pass
        parse_context = OrderedDict([('parent', 'arbitrator'),
                                     ('child', 'alternate'),
                                     ('subChild', 'phones'),
                                     ('subSubChild', 'phone')])

        # We are adding this parse_fields parameter
        # You can read more about this in the clob parser

        parse_fields = OrderedDict([('ID', 'id'),
                                     ('PHONE_NUMBER', 'phoneNumber'),
                                     ('IS_INHERITED', 'isInherited'),
                                     ('subSubChild', 'phone')])

        try:
            result_list = clob_parser.parse2(allOracle88, parse_context, parse_fields)
        except ValueError as error:
            logging.error(error)



        # We will iterate through the collection

        logging.debug("--------------------------------------------------------------------------------")
        logging.debug("CLOB Parse Data")
        logging.debug("Parent - Key:Value")

        for result in result_list:
            result_message = f"{result.get_parent()} - {result.get_key()}:{result.get_value()}"
            logging.debug(result_message)

        logging.debug("Done")
コード例 #5
0
    def run5(self):
        logging.debug('------------------------------------------------------------')
        logging.debug('Inside: ParseDictionary::run()')
        logging.debug("Loading the data file")

        # Phone Data
        phone01 = OrderedDict([('id', '1'), ('phoneNumber', '(605) 336-2880'), ('isInherited', 'Y')])
        phones = OrderedDict([('phone', phone01)])

        # Email Data
        email01 = OrderedDict([('id', '1'), ('address', '*****@*****.**'), ('isInherited', 'Y')])
        emails = OrderedDict([('email', email01)])

        # Education data
        education01 = OrderedDict([('type', 'LE'), ('schoolName', 'Nicholaus Copernicus'), ('graduationDate', '1952')])
        education02 = OrderedDict([('type', 'LW'), ('schoolName', 'Happy LAw School'), ('graduationDate', '1991')])
        education03 = OrderedDict([('type', 'LQ'), ('schoolName', 'Law School Number 1'), ('graduationDate', '1911')])
        educations = OrderedDict([('education', [education01, education02, education03   ]   )])

        allOracle88 = OrderedDict([('arbitrator', OrderedDict([('profileUuid', 'Iaac53e00bd9a11de9b8c850332338889'),
                                                               ('phones', phones),
                                                               ('emails', emails),
                                                               ('educations', educations),
                                                               ('statusType', 'A') ])  )])

        print(json.dumps(allOracle88, indent=2))

        # Note - we might want to use recussion to iterationt his stuff
        # We are fun playing here

        logging.debug("Start parsing ... ")

        clob_parser = module_clob_parser.CLOBParser()

        # search_parent - is required. When found it will return all the children
        # search_keyword - will return a specific child

        # Test Case 1.0 - Pass
        # search_parent = 'arbitrator'
        # search_keyword = 'profileUuid'

        # Test Case 1.1 - Pass
        # search_parent = 'arbitrator'
        # search_keyword = 'statusType'

        # Test Case 2.0 - pass
        search_parent = 'phone'
        search_keyword = ''

        # Test Case 2.1 - pass
        search_parent = 'phone'
        search_keyword = 'id'

        # Test Case 3.0 - pass
        search_parent = 'education'
        search_keyword = ''

        result_list = clob_parser.parse(allOracle88, search_parent, search_keyword)

        # We will iterate through the collection

        logging.debug("--------------------------------------------------------------------------------")
        logging.debug("CLOB Parse Data")
        logging.debug("Parent - Key:Value")

        for result in result_list:
            result_message = f"{result.get_parent()} - {result.get_key()}:{result.get_value()}"
            logging.debug(result_message)

        logging.debug("Done")