def test_create_process_auth_events_on_finished_process_err(pg_conn): orig = create_location(pg_conn, 'Origin') dest = create_location(pg_conn, 'Dest') ctc = create_contact(pg_conn, 'Subject') ckp = create_checkpoint(pg_conn, 'Gate 1') vhc = create_vehicle(pg_conn, 'UUU0000') proc_id = create_process(pg_conn) time.sleep(0.1) update_process(pg_conn, proc_id, ctc, orig, dest, ckp, vhc) terminate_process(pg_conn, proc_id) with pytest.raises(Exception): create_process_auth_event(pg_conn, proc_id, 0, 'sys/none')
def test_process_archive_with_resolved_terminated_process_should_archive_one( pg_conn, basic_flow): orig = create_location(pg_conn, 'Origin') dest = create_location(pg_conn, 'Dest') ctc = create_contact(pg_conn, 'Subject') ckp = create_checkpoint(pg_conn, 'Gate 1') vhc = create_vehicle(pg_conn, 'UUU0000') pk = create_process(pg_conn) time.sleep(0.1) update_process(pg_conn, pk, ctc, orig, dest, ckp, vhc) create_process_auth_event(pg_conn, pk, ctc, 'sys/acc') terminate_process(pg_conn, pk) results = archive_finished_processes(pg_conn) assert results[0]['archived_proc_id'] == pk
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_retrieve_process_histories_by_ids(pg_conn): pk = create_process(pg_conn) create_process_auth_event(pg_conn, pk, 0, 'sys/none') create_process_auth_event(pg_conn, pk, 0, 'sys/none') create_process_auth_event(pg_conn, pk, 0, 'sys/none') rs = retrieve_process_histories_by_ids(pg_conn, (pk,)) assert len(rs) == 3
def test_create_process_auth_event(pg_conn): proc_id = create_process(pg_conn) create_process_auth_event(pg_conn, proc_id, 0, 'sys/none') create_process_auth_event(pg_conn, proc_id, 0, 'sys/none') create_process_auth_event(pg_conn, proc_id, 0, 'sys/none') assert fetch_scalar(pg_conn, 'select count(*) from ac_process_auth_events;') == 3
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_retrieve_process_histories_by_ids_flow(pg_conn, basic_flow): pk = create_process(pg_conn) update_process_auth_flow(pg_conn, pk, basic_flow) create_process_auth_event(pg_conn, pk, 0, 'sys/0001') rs = retrieve_process_histories_by_ids(pg_conn, (pk,)) assert [r['curr_auth_flow_st'] for r in rs] == ['sys/0001'] create_process_auth_event(pg_conn, pk, 0, 'sys/0002') rs = retrieve_process_histories_by_ids(pg_conn, (pk,)) assert [r['curr_auth_flow_st'] for r in rs] == ['sys/0001', 'sys/0002'] create_process_auth_event(pg_conn, pk, 0, 'sys/0003') rs = retrieve_process_histories_by_ids(pg_conn, (pk,)) assert [r['curr_auth_flow_st'] for r in rs] == ['sys/0001', 'sys/0002', 'sys/0003']
def test_create_process_auth_event(pg_conn): created_proc_id = dql_binds.create_process(pg_conn) result = dql_binds.create_process_auth_event(pg_conn, created_proc_id, 0, 'sys/none') assert isinstance(result, datetime.datetime)