Exemple #1
0
def test_add_contact_group_member(pg_conn):
    created_group_name = dql_binds.create_contact_group(pg_conn,
                                                        group_name='group-1')
    created_contact_id = dql_binds.create_contact(pg_conn, 'Joe Manzana')
    result = dql_binds.add_contact_group_member(pg_conn, created_group_name,
                                                created_contact_id)
    assert result is None
Exemple #2
0
def test_remove_contact_from_contact_groups(pg_conn):
    created_group_name = dql_binds.create_contact_group(pg_conn,
                                                        group_name='group-1')
    created_contact_id = dql_binds.create_contact(pg_conn, 'Joe Manzana')
    dql_binds.add_contact_group_member(pg_conn, created_group_name,
                                       created_contact_id)
    result = dql_binds.remove_contact_from_contact_groups(
        pg_conn, created_contact_id, (created_group_name, ))
    assert result is None
Exemple #3
0
def test_retrieve_contacts_by_name(pg_conn, contact_name):
    created_id = dql_binds.create_contact(pg_conn, contact_name)
    records = dql_binds.retrieve_contacts_by_name(pg_conn,
                                                  contact_name,
                                                  page_pos=(contact_name, 0),
                                                  page_size=100)
    assert (len(records) == 1)
    assert (records[0]['contact_id'] == created_id)
    assert (records[0]['contact_name'] == contact_name)
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)
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)
Exemple #6
0
def test_retrieve_contact_groups_by_contact_id(pg_conn):
    created_group_name = dql_binds.create_contact_group(pg_conn,
                                                        group_name='group-1')
    created_contact_id = dql_binds.create_contact(pg_conn, 'Joe Manzana')
    dql_binds.add_contact_group_member(pg_conn, created_group_name,
                                       created_contact_id)
    records = dql_binds.retrieve_contact_groups_by_contact_id(
        pg_conn, created_contact_id)
    assert len(records) == 1
    assert records[0]['group_name'] == 'group-1'
Exemple #7
0
def test_assign_contact_to_location(pg_conn):
    created_location_id = dql_binds.create_location(pg_conn, 'Address 1')
    created_contact_id = dql_binds.create_contact(pg_conn,
                                                  contact_name='Joe Manzana')
    created_assign_type = dql_binds.create_location_assign_type(
        pg_conn, 'Owner')
    result = dql_binds.assign_contact_to_location(pg_conn, created_location_id,
                                                  created_contact_id,
                                                  created_assign_type)
    assert result is None
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']
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')
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 == []
Exemple #12
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)
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
Exemple #14
0
def test_retrieve_location_contact_assignments_by_contact_id(pg_conn):
    created_location_id = dql_binds.create_location(pg_conn, 'Address 1')
    created_contact_id = dql_binds.create_contact(pg_conn,
                                                  contact_name='Joe Manzana')
    created_assign_type = dql_binds.create_location_assign_type(
        pg_conn, 'Owner')
    dql_binds.assign_contact_to_location(pg_conn, created_location_id,
                                         created_contact_id,
                                         created_assign_type)
    records = dql_binds.retrieve_location_contact_assignments_by_contact_id(
        pg_conn, created_contact_id)
    assert len(records) == 1
    assert records[0]['location_id'] == created_location_id
    assert records[0]['addr_1'] == 'Address 1'
    assert records[0]['assign_type'] == 'Owner'
def test_update_process(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)
    update_process(pg_conn, pk, ctc, orig, dest, ckp, vhc)
    rs = retrieve_processes_by_ids(pg_conn, (pk,))
    assert len(rs) == 1
    assert rs[0]['proc_id'] == pk
    assert rs[0]['ctc'] == ctc
    assert rs[0]['vhc'] == vhc
    assert rs[0]['ckp'] == ckp
    assert rs[0]['loc_orig'] == orig
    assert rs[0]['loc_dest'] == dest
Exemple #16
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
Exemple #17
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
Exemple #18
0
def test_delete_contacts_by_ids(pg_conn):
    pk = create_contact(pg_conn, 'Adolf')
    delete_contacts_by_ids(pg_conn, (pk, ))
    rs = retrieve_contacts_by_ids(pg_conn, (pk, ))
    assert len(rs) == 0
Exemple #19
0
def test_update_contact(pg_conn):
    pk = create_contact(pg_conn, 'Adolf')
    update_contact(pg_conn, pk, contact_name='Joe')
    rs = retrieve_contacts_by_ids(pg_conn, (pk, ))
    assert rs[0]['contact_name'] == 'Joe'
Exemple #20
0
def test_create_contact_protected_name_should_err(pg_conn):
    with pytest.raises(Exception):
        create_contact(pg_conn, 'SYSTEM')
Exemple #21
0
def test_update_contact_protected_name_should_err(pg_conn):
    pk = create_contact(pg_conn, 'Adolf')
    with pytest.raises(Exception):
        update_contact(pg_conn, pk, contact_name='SYSTEM')
Exemple #22
0
def test_create_contact(pg_conn):
    created_id = dql_binds.create_contact(pg_conn, contact_name='Joe Manzana')
    assert (isinstance(created_id, int))
Exemple #23
0
def test_retrieve_contacts_by_ids(pg_conn):
    names = ['Adolf', 'Pietro', 'Adam', 'Joan', 'Alex']
    pks = [create_contact(pg_conn, name) for name in names]
    rs = retrieve_contacts_by_ids(pg_conn, tuple(pks))
    assert [r['contact_id'] for r in rs] == pks
    assert [r['contact_name'] for r in rs] == names
Exemple #24
0
def ctc_a2(pg_conn):
    return create_contact(pg_conn, 'ctc_a2')
Exemple #25
0
def test_retrieve_contacts_by_ids(pg_conn):
    created_id = dql_binds.create_contact(pg_conn, 'Mary Garcia')
    records = dql_binds.retrieve_contacts_by_ids(pg_conn, (created_id, ))
    assert (len(records) == 1)
    assert (records[0]['contact_id'] == created_id)
    assert (records[0]['contact_name'] == 'Mary Garcia')
Exemple #26
0
def ctc_a1(pg_conn):
    return create_contact(pg_conn, 'ctc_a1')
Exemple #27
0
def test_update_contact_pk_should_err(pg_conn):
    pk = create_contact(pg_conn, 'Adolf')
    with pytest.raises(Exception):
        pg_conn.execute(
            'update ac_contacts set contact_id=10 where contact_id = %(pk)s',
            {'pk': pk})
Exemple #28
0
def test_create_contact(pg_conn):
    pk = create_contact(pg_conn, 'Adolf')
    rs = retrieve_contacts_by_ids(pg_conn, (pk, ))
    assert len(rs) == 1
    assert rs[0]['contact_id'] == pk
    assert rs[0]['contact_name'] == 'Adolf'
Exemple #29
0
def test_delete_contacts_by_ids(pg_conn):
    created_id = dql_binds.create_contact(pg_conn, 'Joe Manzana')
    result = dql_binds.delete_contacts_by_ids(pg_conn, (created_id, ))
    assert result is None
Exemple #30
0
def test_update_contact(pg_conn):
    created_id = dql_binds.create_contact(pg_conn, 'Mary Garcia')
    result = dql_binds.update_contact(pg_conn,
                                      contact_id=created_id,
                                      contact_name='Ann Garden')
    assert result is None