def test_remove_vehicle_group_members(pg_conn, vhc_a1, vhc_a2): create_vehicle_group(pg_conn, 'group-1') add_vehicle_group_member(pg_conn, 'group-1', vhc_a1) add_vehicle_group_member(pg_conn, 'group-1', vhc_a2) remove_vehicle_group_members(pg_conn, 'group-1', (vhc_a1, )) rs = retrieve_vehicle_group_members(pg_conn, 'group-1') assert rs == [{'vehicle_id': vhc_a2, 'plate': 'AAA9999'}]
def test_delete_vehicle_groups_by_group_names(pg_conn): create_vehicle_group(pg_conn, 'group-1') rs = retrieve_all_vehicle_groups(pg_conn) assert len(rs) == 1 delete_vehicle_groups_by_group_names(pg_conn, ('group-1', )) rs = retrieve_all_vehicle_groups(pg_conn) assert rs == []
def test_retrieve_vehicle_groups_by_vehicle_id(pg_conn, vhc_a1): create_vehicle_group(pg_conn, 'group-1') create_vehicle_group(pg_conn, 'group-2') add_vehicle_group_member(pg_conn, 'group-1', vhc_a1) add_vehicle_group_member(pg_conn, 'group-2', vhc_a1) rs = retrieve_vehicle_groups_by_vehicle_id(pg_conn, vhc_a1) assert rs == [{'group_name': 'group-1'}, {'group_name': 'group-2'}]
def test_retrieve_all_vehicle_groups(pg_conn): create_vehicle_group(pg_conn, 'group-1') create_vehicle_group(pg_conn, 'group-2') rs = retrieve_all_vehicle_groups(pg_conn) assert len(rs) == 2 assert rs[0]['group_name'] == 'group-1' assert rs[1]['group_name'] == 'group-2'
def test_retrieve_all_vehicle_groups(pg_conn): dql_binds.create_vehicle_group(pg_conn, 'group-2') dql_binds.create_vehicle_group(pg_conn, 'group-1') records = dql_binds.retrieve_all_vehicle_groups(pg_conn) assert (len(records) == 2) assert (records[0]['group_name'] == 'group-1') assert (records[1]['group_name'] == 'group-2')
def test_add_vehicle_group_member(pg_conn): created_group_name = dql_binds.create_vehicle_group(pg_conn, group_name='group-1') created_vehicle_id = dql_binds.create_vehicle(pg_conn, 'CCC1010') result = dql_binds.add_vehicle_group_member(pg_conn, created_group_name, created_vehicle_id) assert result is None
def test_remove_vehicle_from_vehicle_groups(pg_conn): created_group_name = dql_binds.create_vehicle_group(pg_conn, group_name='group-1') created_vehicle_id = dql_binds.create_vehicle(pg_conn, 'CCC1010') dql_binds.add_vehicle_group_member(pg_conn, created_group_name, created_vehicle_id) result = dql_binds.remove_vehicle_from_vehicle_groups( pg_conn, created_vehicle_id, (created_group_name, )) assert result is None
def test_retrieve_vehicle_groups_by_vehicle_id(pg_conn): created_group_name = dql_binds.create_vehicle_group(pg_conn, group_name='group-1') created_vehicle_id = dql_binds.create_vehicle(pg_conn, 'CCC1010') dql_binds.add_vehicle_group_member(pg_conn, created_group_name, created_vehicle_id) records = dql_binds.retrieve_vehicle_groups_by_vehicle_id( pg_conn, created_vehicle_id) assert len(records) == 1 assert records[0]['group_name'] == 'group-1'
def test_remove_vehicle_from_vehicle_groups(pg_conn, vhc_a1, vhc_a2): create_vehicle_group(pg_conn, 'group-1') create_vehicle_group(pg_conn, 'group-2') create_vehicle_group(pg_conn, 'group-3') add_vehicle_group_member(pg_conn, 'group-1', vhc_a1) add_vehicle_group_member(pg_conn, 'group-2', vhc_a1) add_vehicle_group_member(pg_conn, 'group-3', vhc_a1) add_vehicle_group_member(pg_conn, 'group-1', vhc_a2) remove_vehicle_from_vehicle_groups(pg_conn, vhc_a1, ('group-1', 'group-3')) rs = retrieve_vehicle_groups_by_vehicle_id(pg_conn, vhc_a1) assert rs == [{'group_name': 'group-2'}] rs = retrieve_vehicle_groups_by_vehicle_id(pg_conn, vhc_a2) assert rs == [{'group_name': 'group-1'}]
def vhcgrp_b(pg_conn): return create_vehicle_group(pg_conn, 'vhcgrp_b')
def test_retrieve_vehicle_group_members(pg_conn, vhc_a1): create_vehicle_group(pg_conn, 'group-1') add_vehicle_group_member(pg_conn, 'group-1', vhc_a1) rs = retrieve_vehicle_group_members(pg_conn, 'group-1') assert rs == [{'vehicle_id': vhc_a1, 'plate': 'GGG0000'}]
def test_add_vehicle_group_member(pg_conn, vhc_a1): create_vehicle_group(pg_conn, 'group-1') add_vehicle_group_member(pg_conn, 'group-1', vhc_a1)
def test_delete_vehicle_groups_by_group_names(pg_conn): created_name = dql_binds.create_vehicle_group(pg_conn, 'group-1') result = dql_binds.delete_vehicle_groups_by_group_names( pg_conn, (created_name, )) assert result is None
def test_update_vehicle_group(pg_conn): created_name = dql_binds.create_vehicle_group(pg_conn, 'group-1') result = dql_binds.update_vehicle_group(pg_conn, group_name=created_name, new_group_name='group-2') assert result is None
def test_update_vehicle_group(pg_conn): create_vehicle_group(pg_conn, 'group-1') update_vehicle_group(pg_conn, 'group-1', 'group-a') rs = retrieve_all_vehicle_groups(pg_conn) assert rs[0]['group_name'] == 'group-a'
def test_create_vehicle_group(pg_conn): created_name = dql_binds.create_vehicle_group(pg_conn, group_name='group-1') assert (isinstance(created_name, str))
def test_create_vehicle_group(pg_conn): create_vehicle_group(pg_conn, 'group-1')