def test_delete_location_assign_types_by_assign_types(pg_conn): create_location_assign_type(pg_conn, 'caretaker', 'Master Caretaker') create_location_assign_type(pg_conn, 'freq-guest', 'Frequent Guest') delete_location_assign_types_by_assign_types(pg_conn, ('freq-guest',)) rs = retrieve_all_location_assign_types(pg_conn) assert len(rs) == 1 assert rs[0]['assign_type'] == 'caretaker'
def test_retrieve_all_location_assign_types(pg_conn): dql_binds.create_location_assign_type(pg_conn, 'Owner') dql_binds.create_location_assign_type(pg_conn, 'Guest') records = dql_binds.retrieve_all_location_assign_types(pg_conn) assert (len(records) == 2) assert (records[0]['assign_type'] == 'Guest') assert (records[1]['assign_type'] == 'Owner')
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]
def test_update_location_assign_type(pg_conn): create_location_assign_type(pg_conn, 'caretaker', 'Master Caretaker') update_location_assign_type(pg_conn, 'caretaker', 'staff', 'Lesser Caretaker') rs = retrieve_all_location_assign_types(pg_conn) assert len(rs) == 1 assert rs[0]['assign_type'] == 'staff' assert rs[0]['assign_desc'] == 'Lesser Caretaker'
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): 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_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_location_assign_types_by_assign_types(pg_conn): created_type = dql_binds.create_location_assign_type(pg_conn, 'Owner') result = dql_binds.delete_location_assign_types_by_assign_types( pg_conn, (created_type, )) assert result is None
def test_update_location_assign_type(pg_conn): created_type = dql_binds.create_location_assign_type(pg_conn, 'Owner') result = dql_binds.update_location_assign_type( pg_conn, created_type, new_assign_type='Maintainer') assert result is None
def test_create_location_assign_type(pg_conn): created_type = dql_binds.create_location_assign_type(pg_conn, 'Owner') assert (isinstance(created_type, str))
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')
def test_create_location_assign_type(pg_conn): create_location_assign_type(pg_conn, 'caretaker')