def test_retrieve_contact_groups_by_contact_id(pg_conn, ctc_a1): create_contact_group(pg_conn, 'group-1') create_contact_group(pg_conn, 'group-2') add_contact_group_member(pg_conn, 'group-1', ctc_a1) add_contact_group_member(pg_conn, 'group-2', ctc_a1) rs = retrieve_contact_groups_by_contact_id(pg_conn, ctc_a1) assert rs == [{'group_name': 'group-1'}, {'group_name': 'group-2'}]
def test_retrieve_all_contact_groups(pg_conn): create_contact_group(pg_conn, 'group-1') create_contact_group(pg_conn, 'group-2') rs = retrieve_all_contact_groups(pg_conn) assert len(rs) == 2 assert rs[0]['group_name'] == 'group-1' assert rs[1]['group_name'] == 'group-2'
def test_delete_contact_groups_by_group_names(pg_conn): create_contact_group(pg_conn, 'group-1') rs = retrieve_all_contact_groups(pg_conn) assert len(rs) == 1 delete_contact_groups_by_group_names(pg_conn, ('group-1', )) rs = retrieve_all_contact_groups(pg_conn) assert rs == []
def test_retrieve_all_contact_groups(pg_conn): dql_binds.create_contact_group(pg_conn, 'Visitors') dql_binds.create_contact_group(pg_conn, 'Employees') records = dql_binds.retrieve_all_contact_groups(pg_conn) assert (len(records) == 2) assert (records[0]['group_name'] == 'Employees') assert (records[1]['group_name'] == 'Visitors')
def test_add_contact_group_member(pg_conn): created_group_name = dql_binds.create_contact_group(pg_conn, group_name='group-1') created_contact_id = dql_binds.create_contact(pg_conn, 'Joe Manzana') result = dql_binds.add_contact_group_member(pg_conn, created_group_name, created_contact_id) assert result is None
def test_remove_contact_from_contact_groups(pg_conn): created_group_name = dql_binds.create_contact_group(pg_conn, group_name='group-1') created_contact_id = dql_binds.create_contact(pg_conn, 'Joe Manzana') dql_binds.add_contact_group_member(pg_conn, created_group_name, created_contact_id) result = dql_binds.remove_contact_from_contact_groups( pg_conn, created_contact_id, (created_group_name, )) assert result is None
def test_retrieve_contact_groups_by_contact_id(pg_conn): created_group_name = dql_binds.create_contact_group(pg_conn, group_name='group-1') created_contact_id = dql_binds.create_contact(pg_conn, 'Joe Manzana') dql_binds.add_contact_group_member(pg_conn, created_group_name, created_contact_id) records = dql_binds.retrieve_contact_groups_by_contact_id( pg_conn, created_contact_id) assert len(records) == 1 assert records[0]['group_name'] == 'group-1'
def test_remove_contact_from_contact_groups(pg_conn, ctc_a1, ctc_a2): create_contact_group(pg_conn, 'group-1') create_contact_group(pg_conn, 'group-2') create_contact_group(pg_conn, 'group-3') add_contact_group_member(pg_conn, 'group-1', ctc_a1) add_contact_group_member(pg_conn, 'group-2', ctc_a1) add_contact_group_member(pg_conn, 'group-3', ctc_a1) add_contact_group_member(pg_conn, 'group-1', ctc_a2) remove_contact_from_contact_groups(pg_conn, ctc_a1, ('group-1', 'group-3')) rs = retrieve_contact_groups_by_contact_id(pg_conn, ctc_a1) assert rs == [{'group_name': 'group-2'}] rs = retrieve_contact_groups_by_contact_id(pg_conn, ctc_a2) assert rs == [{'group_name': 'group-1'}]
def test_create_contact_group(pg_conn): create_contact_group(pg_conn, 'group-1')
def test_retrieve_contact_group_members(pg_conn, ctc_a1): create_contact_group(pg_conn, 'group-1') add_contact_group_member(pg_conn, 'group-1', ctc_a1) rs = retrieve_contact_group_members(pg_conn, 'group-1') assert rs == [{'contact_id': ctc_a1, 'contact_name': 'ctc_a1'}]
def test_add_contact_group_member(pg_conn, ctc_a1): create_contact_group(pg_conn, 'group-1') add_contact_group_member(pg_conn, 'group-1', ctc_a1)
def test_update_contact_group(pg_conn): create_contact_group(pg_conn, 'group-1') update_contact_group(pg_conn, 'group-1', 'group-a') rs = retrieve_all_contact_groups(pg_conn) assert rs[0]['group_name'] == 'group-a'
def test_delete_contact_groups_by_group_names(pg_conn): created_name = dql_binds.create_contact_group(pg_conn, 'group-1') result = dql_binds.delete_contact_groups_by_group_names( pg_conn, (created_name, )) assert result is None
def test_update_contact_group(pg_conn): created_name = dql_binds.create_contact_group(pg_conn, 'Mary Garcia') result = dql_binds.update_contact_group(pg_conn, group_name=created_name, new_group_name='group-2') assert result is None
def test_create_contact_group(pg_conn): created_name = dql_binds.create_contact_group(pg_conn, group_name='group-1') assert (isinstance(created_name, str))
def ctcgrp_b(pg_conn): return create_contact_group(pg_conn, 'ctcgrp_b')