def test_create_auth_flow_st(pg_conn): create_auth_level(pg_conn, 'sys/app', auth_grant=False) create_auth_flow_st(pg_conn, 0, 'sys/app', False) rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0) assert len(rs) == 2 assert rs[0]['st_name'] == 'sys/app' assert rs[0]['st_term'] is False
def test_retrieve_auth_flow_sts_by_auth_flow_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_flow_st(pg_conn, 0, 'sys/1', False) create_auth_flow_st(pg_conn, 0, 'sys/2', True) rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0) assert rs[0] == {'st_name': 'sys/1', 'st_term': False} assert rs[1] == {'st_name': 'sys/2', 'st_term': True} assert rs[2] == {'st_name': 'sys/none', 'st_term': False}
def test_update_auth_flow_st_pk_should_err(pg_conn): create_auth_level(pg_conn, 'sys/app', auth_grant=False) create_auth_flow_st(pg_conn, 0, 'sys/app', False) flow_id = create_auth_flow(pg_conn, auth_flow_desc='Main Flow') with pytest.raises(Exception): pg_conn.execute( 'update ac_auth_flow_sts set auth_flow_id=%(flow_id)s where auth_flow_id = %(pk)s', { 'pk': 0, 'flow_id': flow_id })
def test_retrieve_auth_flow_sts_by_auth_flow_id(pg_conn): created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary') created_auth_name = dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True) dql_binds.create_auth_flow_st(pg_conn, created_flow_id, created_auth_name, st_term=False) records = dql_binds.retrieve_auth_flow_sts_by_auth_flow_id( pg_conn, created_flow_id) assert len(records) != 0
def test_delete_auth_flow_st_by_id(pg_conn): created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary') created_auth_name = dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True) dql_binds.create_auth_flow_st(pg_conn, created_flow_id, created_auth_name, st_term=False) result = dql_binds.delete_auth_flow_st_by_id(pg_conn, created_flow_id, created_auth_name) assert result is None
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
def test_create_auth_flow_st(pg_conn): created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary') created_auth_name = dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True) created_record = dql_binds.create_auth_flow_st(pg_conn, created_flow_id, created_auth_name, st_term=False) assert created_record['auth_flow_id'] == created_flow_id assert created_record['st_name'] == created_auth_name
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
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
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
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
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'
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')
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
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
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
def test_delete_auth_flow_st_by_id(pg_conn): create_auth_level(pg_conn, 'sys/app', auth_grant=False) create_auth_flow_st(pg_conn, 0, 'sys/app', False) delete_auth_flow_st_by_id(pg_conn, 0, 'sys/app') rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0) assert len(rs) == 1
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'
def test_update_auth_flow_st(pg_conn): create_auth_level(pg_conn, 'sys/app', auth_grant=False) create_auth_flow_st(pg_conn, 0, 'sys/app', False) update_auth_flow_st(pg_conn, 0, 'sys/app', True) rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0) assert rs[0]['st_term'] is True