Exemplo n.º 1
0
def test_terminate_process_no_ctc(pg_conn):
    orig = create_location(pg_conn, 'Origin')
    dest = create_location(pg_conn, 'Dest')
    ckp = create_checkpoint(pg_conn, 'Gate 1')
    vhc = create_vehicle(pg_conn, 'UUU0000')
    pk = create_process(pg_conn)
    time.sleep(0.01)
    update_process(pg_conn, pk, None, orig, dest, ckp, vhc)
    with pytest.raises(Exception):
        terminate_process(pg_conn, pk)
Exemplo n.º 2
0
def test_terminate_process_no_orig(pg_conn):
    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.01)
    update_process(pg_conn, pk, ctc, None, dest, ckp, vhc)
    with pytest.raises(Exception):
        terminate_process(pg_conn, pk)
Exemplo n.º 3
0
def test_terminate_process_no_ckp(pg_conn):
    orig = create_location(pg_conn, 'Origin')
    dest = create_location(pg_conn, 'Dest')
    ctc = create_contact(pg_conn, 'Subject')
    vhc = create_vehicle(pg_conn, 'UUU0000')
    pk = create_process(pg_conn)
    time.sleep(0.01)
    update_process(pg_conn, pk, ctc, orig, dest, None, vhc)
    with pytest.raises(Exception):
        terminate_process(pg_conn, pk)
Exemplo n.º 4
0
def test_terminate_process_no_vhc(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')
    pk = create_process(pg_conn)
    time.sleep(0.01)
    update_process(pg_conn, pk, ctc, orig, dest, ckp, None)
    terminate_process(pg_conn, pk)
    rs = retrieve_processes_by_ids(pg_conn, (pk,))
    assert rs[0]['finished_at']
Exemplo n.º 5
0
def test_update_process_finished_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')
    pk = create_process(pg_conn)
    time.sleep(0.01)
    update_process(pg_conn, pk, ctc, orig, dest, ckp, vhc)
    terminate_process(pg_conn, pk)
    with pytest.raises(Exception):
        update_process(pg_conn, pk, ctc, orig, dest, ckp, vhc)
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')
Exemplo n.º 7
0
def test_process_archive_with_unresolved_terminated_process_should_archive_none(
        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')
    pk = create_process(pg_conn)
    time.sleep(0.1)
    update_process(pg_conn, pk, ctc, orig, dest, ckp, vhc)
    terminate_process(pg_conn, pk)
    results = archive_finished_processes(pg_conn)
    assert results == []
Exemplo n.º 8
0
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
Exemplo n.º 9
0
def test_terminate_process(pg_conn):
    created_proc_id = dql_binds.create_process(pg_conn)
    created_ctc_id = dql_binds.create_contact(pg_conn, 'Joe')
    created_orig_id = dql_binds.create_location(pg_conn, 'Addr 1')
    created_dest_id = dql_binds.create_location(pg_conn, 'Addr 2')
    created_ckp_id = dql_binds.create_checkpoint(pg_conn, 'Gate 1')
    result = dql_binds.update_process(pg_conn,
                                      created_proc_id,
                                      ctc=created_ctc_id,
                                      loc_orig=created_orig_id,
                                      loc_dest=created_dest_id,
                                      ckp=created_ckp_id)
    result = dql_binds.terminate_process(pg_conn, created_proc_id)
    assert isinstance(result, datetime.datetime)
Exemplo n.º 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