示例#1
0
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'}]
示例#2
0
def test_retrieve_all_location_groups(pg_conn):
    dql_binds.create_location_group(pg_conn, 'Area 1')
    dql_binds.create_location_group(pg_conn, 'Area 2')
    records = dql_binds.retrieve_all_location_groups(pg_conn)
    assert (len(records) == 2)
    assert (records[0]['group_name'] == 'Area 1')
    assert (records[1]['group_name'] == 'Area 2')
示例#3
0
def test_retrieve_all_location_groups(pg_conn):
    create_location_group(pg_conn, 'group-1')
    create_location_group(pg_conn, 'group-2')
    rs = retrieve_all_location_groups(pg_conn)
    assert len(rs) == 2
    assert rs[0]['group_name'] == 'group-1'
    assert rs[1]['group_name'] == 'group-2'
示例#4
0
def test_delete_location_groups_by_group_names(pg_conn):
    create_location_group(pg_conn, 'group-1')
    rs = retrieve_all_location_groups(pg_conn)
    assert len(rs) == 1
    delete_location_groups_by_group_names(pg_conn, ('group-1', ))
    rs = retrieve_all_location_groups(pg_conn)
    assert rs == []
示例#5
0
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
    }]
示例#6
0
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
示例#7
0
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
示例#8
0
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'
示例#9
0
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
示例#10
0
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'}]
示例#11
0
def test_delete_location_groups_by_group_names(pg_conn):
    created_name = dql_binds.create_location_group(pg_conn, 'group-1')
    result = dql_binds.delete_location_groups_by_group_names(
        pg_conn, (created_name, ))
    assert result is None
示例#12
0
def test_update_location_group(pg_conn):
    created_name = dql_binds.create_location_group(pg_conn, 'group-1')
    result = dql_binds.update_location_group(pg_conn,
                                             group_name=created_name,
                                             new_group_name='group-2')
    assert result is None
示例#13
0
def test_create_location_group(pg_conn):
    created_name = dql_binds.create_location_group(pg_conn,
                                                   group_name='group-1')
    assert (isinstance(created_name, str))
示例#14
0
def test_create_location_group(pg_conn):
    create_location_group(pg_conn, 'group-1')
示例#15
0
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)
示例#16
0
def locgrp_b(pg_conn):
    return create_location_group(pg_conn, 'locgrp_b')
示例#17
0
def test_update_location_group(pg_conn):
    create_location_group(pg_conn, 'group-1')
    update_location_group(pg_conn, 'group-1', 'group-a')
    rs = retrieve_all_location_groups(pg_conn)
    assert rs[0]['group_name'] == 'group-a'