def test_get_private_limit(request, connection): # Get the current number of public address books in case the account # has some data in that we need to take into consideration existing_books = AddressBook.get_all(address_book_type='Private') offset = len(existing_books) # Generate a number of address books new_address_books = [] for x in range(1, 10): new_address_books.append( AddressBook(name='Address Book %s' % x, visibility=constants.VISIBILITY_PRIVATE)) new_address_books[-1].create() # Define a finalizer for the test request so we make sure we clean # up after ourselves def cleanup(): for book in new_address_books: manually_delete_address_book(connection, book) request.addfinalizer(cleanup) books = AddressBook.get_private(select=5, skip=offset) for book in new_address_books[:5]: assert book in books
def test_get_private(sample_address_book, sample_public_address_book): address_books = AddressBook.get_all(address_book_type='Private') for book in address_books: print book.id, book.name, book.visibility assert sample_address_book in address_books assert sample_public_address_book not in address_books
def test_delete_protected_address_book(book_name): """ Test to confirm that if the delete end point is called on one of the protected address books (All Contacts and Test), then the appropriate exception is raised. :param book_name: :return: """ test_book = None # Get a list of all address books in the account. books = AddressBook.get_all() print books # Find the test address book and grab it's ID value for book in books: log.info("Address book: {}".format(book.name)) print book.name if book.name == book_name: test_book = book break # Assert that the test book has been found, otherwise stop here assert test_book is not None # Confirm that the class method version raises the correct exception with pytest.raises(ErrorAddressbookNotwritable): AddressBook.delete(test_book.id) # Confirm that the instance method version raises the correct # exception with pytest.raises(ErrorAddressbookNotwritable): test_book.delete()