def test_unexpected_response(self): connection = MockPortalConnection( _simulate_create_static_contact_list_with_unsupported_response, ) with assert_raises(Invalid): with connection: create_static_contact_list(_STUB_CONTACT_LIST.name, connection)
def test_name_already_exists(self): exception = HubspotClientError('Whoops!', 1) simulator = UnsuccessfulCreateStaticContactList( _STUB_CONTACT_LIST.name, exception, ) with assert_raises_regexp(HubspotClientError, str(exception)): with MockPortalConnection(simulator) as connection: create_static_contact_list(_STUB_CONTACT_LIST.name, connection)
def test_name_doesnt_exist(self): simulator = CreateStaticContactList(_STUB_CONTACT_LIST.name) with MockPortalConnection(simulator) as connection: contact_list = create_static_contact_list( _STUB_CONTACT_LIST.name, connection, ) eq_(_STUB_CONTACT_LIST, contact_list)
def test_static_lists(): with _get_portal_connection() as connection: new_contact_list_name = 'contactlisttest' created_static_list = \ create_static_contact_list(new_contact_list_name, connection) eq_(new_contact_list_name, created_static_list.name) all_contact_lists = get_all_contact_lists(connection) assert_in(created_static_list, all_contact_lists) all_contacts = get_all_contacts(connection) first_contact = next(all_contacts) added_contact_vids = add_contacts_to_list( created_static_list, [first_contact], connection, ) assert_in(first_contact.vid, added_contact_vids) contacts_in_list = list( get_all_contacts_from_list(connection, created_static_list) ) assert_in(first_contact, contacts_in_list) removed_contact_vids = remove_contacts_from_list( created_static_list, [first_contact], connection, ) assert_in(first_contact.vid, removed_contact_vids) contacts_in_list = list( get_all_contacts_from_list(connection, created_static_list) ) assert_not_in(first_contact, contacts_in_list) delete_contact_list(created_static_list.id, connection) all_contact_lists = get_all_contact_lists(connection) assert_not_in(created_static_list, all_contact_lists)