def test_rule_match_success_dest_ctc_assign_same(pg_conn, loc_a1, loc_b1,
                                                 ctc_a1, ctc_b1):
    create_location_assign_type(pg_conn, 'keeper', 'Keeper')
    create_location_assign_type(pg_conn, 'dweller', 'Dweller')
    assign_contact_to_location(pg_conn, loc_a1, ctc_a1, 'dweller')
    assign_contact_to_location(pg_conn, loc_a1, ctc_b1, 'keeper')
    rule_1 = _create_auth_rule(pg_conn, 1, 'sys/none')
    rule_2 = _create_auth_rule(pg_conn, 2, 'sys/none')
    rule_3 = _create_auth_rule(pg_conn, 3, 'sys/none')
    patch_auth_rule(pg_conn, rule_1, loc_ass='dweller')
    patch_auth_rule(pg_conn, rule_2, loc_ass='keeper')
    proc_1 = create_process(pg_conn)
    proc_2 = create_process(pg_conn)
    proc_3 = create_process(pg_conn)
    update_process(pg_conn, proc_1, ctc_a1, None, loc_a1, None,
                   None)  # assignee aiming correct loc
    update_process(pg_conn, proc_2, ctc_b1, None, loc_a1, None,
                   None)  # assignee aiming correct loc
    update_process(pg_conn, proc_3, ctc_b1, None, loc_b1, None,
                   None)  # assignee aiming incorrect loc
    processes_matches = retrieve_processes_rule_matches(pg_conn)
    grouped = toolz.groupby('proc_id', processes_matches)
    assert _proc_matches(grouped, proc_1) == [rule_1, rule_3]
    assert _proc_matches(grouped, proc_2) == [rule_2, rule_3]
    assert _proc_matches(grouped, proc_3) == [rule_3]
Example #2
0
def test_delete_contact_location_assignment(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)
    result = dql_binds.delete_contact_location_assignment(
        pg_conn, created_location_id, created_contact_id, created_assign_type)
    assert result is None
Example #3
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_delete_contact_location_assignment(pg_conn, ctc_a1, ctc_b1, loc_a1, loc_b1):
    create_location_assign_type(pg_conn, 'caretaker', 'Master Caretaker')
    create_location_assign_type(pg_conn, 'houndmaster', 'Kennel Master')
    assign_contact_to_location(pg_conn, loc_a1, ctc_a1, 'caretaker')
    assign_contact_to_location(pg_conn, loc_b1, ctc_a1, 'houndmaster')
    assign_contact_to_location(pg_conn, loc_b1, ctc_b1, 'caretaker')
    delete_contact_location_assignment(pg_conn, loc_b1, ctc_b1, 'caretaker')
    rs = retrieve_location_contact_assignments(pg_conn, loc_b1)
    assert rs == [{'contact_id': ctc_a1, 'contact_name': 'ctc_a1', 'assign_type': 'houndmaster'}]
def test_retrieve_location_contact_assignments_by_contact_id(pg_conn, ctc_a1, ctc_b1, loc_a1, loc_b1):
    create_location_assign_type(pg_conn, 'caretaker', 'Master Caretaker')
    create_location_assign_type(pg_conn, 'houndmaster', 'Kennel Master')
    assign_contact_to_location(pg_conn, loc_a1, ctc_a1, 'caretaker')
    assign_contact_to_location(pg_conn, loc_b1, ctc_a1, 'houndmaster')
    assign_contact_to_location(pg_conn, loc_b1, ctc_b1, 'caretaker')
    rs = retrieve_location_contact_assignments_by_contact_id(pg_conn, ctc_a1)
    assert len(rs) == 2
    assert rs[0] == {'location_id': loc_a1, 'addr_1': 'loc_a1', 'addr_2': None, 'addr_3': None, 'addr_4': None, 'addr_5': None, 'addr_6': None, 'assign_type': 'caretaker'}
    assert rs[1] == {'location_id': loc_b1, 'addr_1': 'loc_b1', 'addr_2': None, 'addr_3': None, 'addr_4': None, 'addr_5': None, 'addr_6': None, 'assign_type': 'houndmaster'}
    rs = retrieve_location_contact_assignments_by_contact_id(pg_conn, ctc_b1)
    assert len(rs) == 1
    assert rs[0] == {'location_id': loc_b1, 'addr_1': 'loc_b1', 'addr_2': None, 'addr_3': None, 'addr_4': None, 'addr_5': None, 'addr_6': None, 'assign_type': 'caretaker'}
def test_assign_contact_to_location(pg_conn, ctc_nogrp, loc_nogrp):
    create_location_assign_type(pg_conn, 'caretaker', 'Master Caretaker')
    assign_contact_to_location(pg_conn, loc_nogrp, ctc_nogrp, 'caretaker')