def test_retrieve_location_groups_by_location_id(pg_conn, loc_a1): create_location_group(pg_conn, 'group-1') create_location_group(pg_conn, 'group-2') add_location_group_member(pg_conn, 'group-1', loc_a1) add_location_group_member(pg_conn, 'group-2', loc_a1) rs = retrieve_location_groups_by_location_id(pg_conn, loc_a1) assert rs == [{'group_name': 'group-1'}, {'group_name': 'group-2'}]
def test_remove_location_from_location_groups(pg_conn): created_group_name = dql_binds.create_location_group(pg_conn, group_name='group-1') created_location_id = dql_binds.create_location(pg_conn, 'Address 1') dql_binds.add_location_group_member(pg_conn, created_group_name, created_location_id) result = dql_binds.remove_location_from_location_groups( pg_conn, created_location_id, (created_group_name, )) assert result is None
def test_retrieve_location_groups_by_location_id(pg_conn): created_group_name = dql_binds.create_location_group(pg_conn, group_name='group-1') created_location_id = dql_binds.create_location(pg_conn, 'Address 1') dql_binds.add_location_group_member(pg_conn, created_group_name, created_location_id) records = dql_binds.retrieve_location_groups_by_location_id( pg_conn, created_location_id) assert len(records) == 1 assert records[0]['group_name'] == 'group-1'
def test_retrieve_location_group_members(pg_conn, loc_a1): create_location_group(pg_conn, 'group-1') add_location_group_member(pg_conn, 'group-1', loc_a1) rs = retrieve_location_group_members(pg_conn, 'group-1') assert rs == [{ 'location_id': loc_a1, 'addr_1': 'loc_a1', 'addr_2': None, 'addr_3': None, 'addr_4': None, 'addr_5': None, 'addr_6': None }]
def test_retrieve_location_group_members(pg_conn): created_group_name = dql_binds.create_location_group(pg_conn, group_name='group-1') created_location_id = dql_binds.create_location(pg_conn, 'Address 1') dql_binds.add_location_group_member(pg_conn, created_group_name, created_location_id) records = dql_binds.retrieve_location_group_members( pg_conn, created_group_name) assert len(records) == 1 assert records[0]['addr_1'] == 'Address 1' assert records[0]['addr_2'] is None assert records[0]['addr_3'] is None assert records[0]['addr_4'] is None assert records[0]['addr_5'] is None assert records[0]['addr_6'] is None
def test_add_location_group_member(pg_conn): created_group_name = dql_binds.create_location_group(pg_conn, group_name='group-1') created_location_id = dql_binds.create_location(pg_conn, 'Address 1') result = dql_binds.add_location_group_member(pg_conn, created_group_name, created_location_id) assert result is None
def test_remove_location_from_location_groups(pg_conn, loc_a1, loc_a2): create_location_group(pg_conn, 'group-1') create_location_group(pg_conn, 'group-2') create_location_group(pg_conn, 'group-3') add_location_group_member(pg_conn, 'group-1', loc_a1) add_location_group_member(pg_conn, 'group-2', loc_a1) add_location_group_member(pg_conn, 'group-3', loc_a1) add_location_group_member(pg_conn, 'group-1', loc_a2) remove_location_from_location_groups(pg_conn, loc_a1, ('group-1', 'group-3')) rs = retrieve_location_groups_by_location_id(pg_conn, loc_a1) assert rs == [{'group_name': 'group-2'}] rs = retrieve_location_groups_by_location_id(pg_conn, loc_a2) assert rs == [{'group_name': 'group-1'}]
def loc_b1(pg_conn, locgrp_b): loc = create_location(pg_conn, 'loc_b1') add_location_group_member(pg_conn, 'locgrp_b', loc) return loc
def test_add_location_group_member(pg_conn, loc_a1): create_location_group(pg_conn, 'group-1') add_location_group_member(pg_conn, 'group-1', loc_a1)