Example #1
0
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()
Example #2
0
def test_delete_invalid_address_book():
    with pytest.raises(ErrorAddressbookNotFound):
        AddressBook.delete(999999999)