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_create_process_should_use_auth_flow_setting(pg_conn): pk = create_process(pg_conn) rs = retrieve_processes_by_ids(pg_conn, (pk,)) active_flow = retrieve_current_active_auth_flow(pg_conn) assert rs[0]['auth_flow'] == active_flow['auth_flow_id'] auth_flow_1 = create_auth_flow(pg_conn, 'Flow 1') update_current_active_auth_flow(pg_conn, auth_flow_1) pk = create_process(pg_conn) rs = retrieve_processes_by_ids(pg_conn, (pk,)) assert rs[0]['auth_flow'] == auth_flow_1 auth_flow_2 = create_auth_flow(pg_conn, 'Flow 2') update_current_active_auth_flow(pg_conn, auth_flow_2) pk = create_process(pg_conn) rs = retrieve_processes_by_ids(pg_conn, (pk,)) assert rs[0]['auth_flow'] == auth_flow_2
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_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_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 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 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_update_auth_flow_tr_pk_should_err(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/1', 'sys/2', 'sys/3') flow_id = create_auth_flow(pg_conn, auth_flow_desc='Main Flow') # create_auth_flow_st(pg_conn, flow_id, 'sys/1', st_term=False) # create_auth_flow_st(pg_conn, flow_id, 'sys/2', st_term=False) # create_auth_flow_st(pg_conn, flow_id, 'sys/3', st_term=False) with pytest.raises(Exception): pg_conn.execute( 'update ac_auth_flow_trs set auth_flow_id=%(flow_id)s where auth_flow_id = 0', {'flow_id': flow_id})
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_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 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_delete_auth_flows_by_ids(pg_conn): pk = create_auth_flow(pg_conn, auth_flow_desc='Main Flow') delete_auth_flows_by_ids(pg_conn, (pk, )) rs = retrieve_auth_flows_by_ids(pg_conn, (pk, )) assert len(rs) == 0
def test_update_current_active_auth_flow(pg_conn): created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary') result = dql_binds.update_current_active_auth_flow(pg_conn, created_flow_id) assert result is None
def test_retrieve_auth_flows_by_ids(pg_conn): created_id = dql_binds.create_auth_flow(pg_conn, 'primary') records = dql_binds.retrieve_auth_flows_by_ids(pg_conn, (created_id, )) assert len(records) == 1 assert records[0]['auth_flow_desc'] == 'primary'
def test_create_auth_flow(pg_conn): created_id = dql_binds.create_auth_flow(pg_conn, 'primary') assert isinstance(created_id, int)
def test_create_auth_flow(pg_conn): pk = create_auth_flow(pg_conn, 'Flow 1') rs = retrieve_auth_flows_by_ids(pg_conn, (pk, )) assert len(rs) == 1 assert rs[0]['auth_flow_id'] == pk assert rs[0]['auth_flow_desc'] == 'Flow 1'
def test_delete_auth_flow_referenced_should_err(pg_conn): auth_flow = create_auth_flow(pg_conn, 'Flow 1') proc_id = create_process(pg_conn) update_process_auth_flow(pg_conn, proc_id, auth_flow) with pytest.raises(Exception): delete_auth_flows_by_ids(pg_conn, (auth_flow, ))
def test_update_auth_flow(pg_conn): pk = create_auth_flow(pg_conn, 'Flow 1') update_auth_flow(pg_conn, pk, auth_flow_desc='Flow 30') rs = retrieve_auth_flows_by_ids(pg_conn, (pk, )) assert rs[0]['auth_flow_desc'] == 'Flow 30'
def test_retrieve_auth_flows_by_ids(pg_conn): infos = ['Flow 1', 'Flow 12', 'Flow 10'] pks = [create_auth_flow(pg_conn, info) for info in infos] rs = retrieve_auth_flows_by_ids(pg_conn, tuple(pks)) assert [r['auth_flow_id'] for r in rs] == pks assert [r['auth_flow_desc'] for r in rs] == infos
def test_delete_auth_flows_by_ids(pg_conn): created_id = dql_binds.create_auth_flow(pg_conn, 'primary') result = dql_binds.delete_auth_flows_by_ids(pg_conn, (created_id, )) assert result is None
def test_update_auth_flow(pg_conn): created_id = dql_binds.create_auth_flow(pg_conn, 'primary') result = dql_binds.update_auth_flow(pg_conn, created_id, 'secondary') assert result is None
def test_update_auth_flow_referenced_should_err(pg_conn): auth_flow = create_auth_flow(pg_conn, 'Flow 1') proc_id = create_process(pg_conn) update_process_auth_flow(pg_conn, proc_id, auth_flow) with pytest.raises(Exception): update_auth_flow(pg_conn, auth_flow, auth_flow_desc='Flow 120')