Example #1
0
def test_hframe_rw_db():
    """
    Create a pb buffer
    write to db
    read from db
    :return:
    """
    global engine_g
    """ Create table """

    hyperframe.HyperFrameRecord.create_table(engine_g)
    """ Create some PB records """

    hf1 = _make_hframe_record('inner_record')
    hf2 = _make_hframe_record('outer_record', hframes=[
        hf1,
    ])
    """ Write out PBs as rows """

    hf_hash = hashlib.md5(hf2.pb.SerializeToString()).hexdigest()
    w_pb_db(hf2, engine_g)
    """ Read in PBs as rows"""

    hf_results = r_pb_db(hyperframe.HyperFrameRecord, engine_g)

    hf_hash2 = None
    for x in hf_results:
        hf_hash2 = hashlib.md5(x.pb.SerializeToString()).hexdigest()

    assert (hf_hash == hf_hash2)
Example #2
0
def test_linkauth_rw_db():
    """
    Create a pb buffer
    write to db
    read from db
    :return:
    """
    global engine_g
    """ Create table """

    hyperframe.LinkAuthBase.create_table(engine_g)
    """ Create some PB records """

    slar = _make_linkauth_records()
    """ Write out PBs as rows """

    slar_hash = hashlib.md5(slar.pb.SerializeToString()).hexdigest()
    w_pb_db(slar, engine_g)
    """ Read in PBs as rows"""

    link_auth_results = r_pb_db(hyperframe.LinkAuthBase, engine_g)

    slar_hash2 = None
    for x in link_auth_results:
        if x.pb.WhichOneof('auth') == 's3_auth':
            slar_hash2 = hashlib.md5(x.pb.SerializeToString()).hexdigest()

    assert (slar_hash == slar_hash2)
Example #3
0
def test_link_rw_db():
    """
    Create a pb buffer
    write to db
    read from db
    :return:
    """
    global engine_g

    """ Create table """

    hyperframe.LinkBase.create_table(engine_g)

    """ Create some PB records """

    local_link, s3_link, db_link = _make_link_records()

    """ Write out PBs as rows """

    local_hash = w_pb_db(local_link, engine_g)
    s3_hash = w_pb_db(s3_link, engine_g)
    db_hash = w_pb_db(db_link, engine_g)

    """ Read in PBs as rows"""

    link_results = r_pb_db(hyperframe.LinkBase, engine_g)

    local_hash2 = None
    s3_hash2 = None
    db_hash2 = None
    for x in link_results:
        if x.pb.WhichOneof('link') == 'local':
            local_hash2 = hashlib.md5(local_link.pb.SerializeToString()).hexdigest()
        if x.pb.WhichOneof('link') == 's3':
            s3_hash2 = hashlib.md5(s3_link.pb.SerializeToString()).hexdigest()
        if x.pb.WhichOneof('link') == 'database':
            db_hash2 = hashlib.md5(db_link.pb.SerializeToString()).hexdigest()

    assert (local_hash == local_hash2)
    assert (s3_hash == s3_hash2)
    assert (db_hash == db_hash2)