示例#1
0
def test_update_auth_flow_tr(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_level(pg_conn, 'sys/3', auth_grant=False)
    create_auth_level(pg_conn, 'sys/10', auth_grant=False)
    create_auth_level(pg_conn, 'sys/20', auth_grant=False)
    create_auth_level(pg_conn, 'sys/30', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/3', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/10', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/20', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/30', st_term=False)
    create_auth_flow_tr(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    update_auth_flow_tr(pg_conn,
                        0,
                        'sys/2',
                        'sys/1',
                        'sys/3',
                        new_when_ev='sys/20',
                        new_curr_st='sys/10',
                        new_next_st='sys/30')
    rs = retrieve_auth_flow_trs_by_auth_flow_id(pg_conn, 0)
    assert rs[0]['auth_flow_id'] == 0
    assert rs[0]['curr_st'] == 'sys/10'
    assert rs[0]['when_ev'] == 'sys/20'
    assert rs[0]['next_st'] == 'sys/30'
示例#2
0
def test_update_auth_flow_tr(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/1', 'sys/2',
                                  'sys/3')
    result = dql_binds.update_auth_flow_tr(pg_conn,
                                           created_flow_id,
                                           'sys/2',
                                           'sys/1',
                                           'sys/3',
                                           new_curr_st='sys/1',
                                           new_when_ev='sys/2',
                                           new_next_st='sys/3')
    assert result is None
示例#3
0
def test_delete_auth_flow_tr_by_id(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_level(pg_conn, 'sys/3', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/3', st_term=False)
    create_auth_flow_tr(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    delete_auth_flow_tr_by_id(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    rs = retrieve_auth_flow_trs_by_auth_flow_id(pg_conn, 0)
    assert len(rs) == 0
示例#4
0
def basic_flow(pg_conn, basic_levels):
    auth_flow = create_auth_flow(pg_conn)
    create_auth_flow_st(pg_conn, auth_flow, 'sys/0001', st_term=False)
    create_auth_flow_st(pg_conn, auth_flow, 'sys/0002', st_term=False)
    create_auth_flow_st(pg_conn, auth_flow, 'sys/0003', st_term=False)
    create_auth_flow_st(pg_conn, auth_flow, 'sys/0004', st_term=False)
    create_auth_flow_st(pg_conn, auth_flow, 'sys/0005', st_term=False)
    create_auth_flow_tr(pg_conn, auth_flow, when_ev='sys/0001', curr_st='sys/none', next_st='sys/0001')
    create_auth_flow_tr(pg_conn, auth_flow, when_ev='sys/0002', curr_st='sys/0001', next_st='sys/0002')
    create_auth_flow_tr(pg_conn, auth_flow, when_ev='sys/0003', curr_st='sys/0002', next_st='sys/0003')
    create_auth_flow_tr(pg_conn, auth_flow, when_ev='sys/0004', curr_st='sys/0003', next_st='sys/0004')
    create_auth_flow_tr(pg_conn, auth_flow, when_ev='sys/0005', curr_st='sys/0004', next_st='sys/0005')
    return auth_flow
示例#5
0
def test_create_auth_flow_tr(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_level(pg_conn, 'sys/3', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/3', st_term=False)
    create_auth_flow_tr(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    rs = retrieve_auth_flow_trs_by_auth_flow_id(pg_conn, 0)
    assert len(rs) == 1
    assert rs[0]['auth_flow_id'] == 0
    assert rs[0]['curr_st'] == 'sys/1'
    assert rs[0]['when_ev'] == 'sys/2'
    assert rs[0]['next_st'] == 'sys/3'
示例#6
0
def test_create_auth_flow_tr(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/2', 'sys/1',
                                  'sys/3')
示例#7
0
def test_retrieve_process_histories_by_ids(pg_conn):
    dql_binds.create_auth_level(pg_conn, 'sys/acc', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn, 0, 'sys/acc', st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, 0, 'sys/acc', 'sys/none', 'sys/acc')

    created_proc_id = dql_binds.create_process(pg_conn)
    ctc = dql_binds.create_contact(pg_conn, 'Joe')
    loc_orig = dql_binds.create_location(pg_conn, 'Addr 1')
    loc_dest = dql_binds.create_location(pg_conn, 'Addr 2')
    ckp = dql_binds.create_checkpoint(pg_conn, 'Gate 1')
    dql_binds.update_process(pg_conn,
                             created_proc_id,
                             ctc=ctc,
                             loc_orig=loc_orig,
                             loc_dest=loc_dest,
                             ckp=ckp)
    dql_binds.create_process_auth_event(pg_conn, created_proc_id, ctc,
                                        'sys/acc')
    result = dql_binds.retrieve_process_histories_by_ids(
        pg_conn, (created_proc_id, ))
    assert result
示例#8
0
def test_delete_auth_flow_tr_by_id(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/2', 'sys/1',
                                  'sys/3')
    result = dql_binds.delete_auth_flow_tr_by_id(pg_conn, created_flow_id,
                                                 'sys/2', 'sys/1', 'sys/3')
    assert result is None
示例#9
0
def test_retrieve_auth_flow_trs_by_auth_flow_id(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/2', 'sys/1',
                                  'sys/3')
    records = dql_binds.retrieve_auth_flow_trs_by_auth_flow_id(
        pg_conn, created_flow_id)
    assert len(records) == 1
示例#10
0
def test_archive_finished_processes(pg_conn):
    dql_binds.create_auth_level(pg_conn, 'sys/acc', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn, 0, 'sys/acc', st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, 0, 'sys/acc', 'sys/none', 'sys/acc')

    created_proc_id = dql_binds.create_process(pg_conn)
    ctc = dql_binds.create_contact(pg_conn, 'Joe')
    loc_orig = dql_binds.create_location(pg_conn, 'Addr 1')
    loc_dest = dql_binds.create_location(pg_conn, 'Addr 2')
    ckp = dql_binds.create_checkpoint(pg_conn, 'Gate 1')
    dql_binds.update_process(pg_conn,
                             created_proc_id,
                             ctc=ctc,
                             loc_orig=loc_orig,
                             loc_dest=loc_dest,
                             ckp=ckp)

    dql_binds.create_process_auth_event(pg_conn, created_proc_id, ctc,
                                        'sys/acc')
    time.sleep(0.1)
    dql_binds.terminate_process(pg_conn, created_proc_id)
    result = dql_binds.archive_finished_processes(pg_conn)
    assert result
示例#11
0
def basic_flow(pg_conn):
    create_auth_level(pg_conn, 'sys/acc', auth_grant=True)
    create_auth_flow_st(pg_conn, 0, 'sys/acc', st_term=True)
    create_auth_flow_tr(pg_conn, 0, 'sys/acc', 'sys/none', 'sys/acc')
    return 0