Example #1
0
def test_delete_valid_address_book(sample_address_book):
    """
    Test to confirm that the delete functionality for address books 
    behaves  correctly.  Calling the delete on an address book should 
    update the ID attribute of the address book to be null, whilst also
    triggering DotMailer to remove the address book from the account.
    
    :param sample_address_book: 
    :return: 
    """
    address_book_id = sample_address_book.id
    assert address_book_id is not None, 'Sample address book doesn\'t' \
                                        ' have an ID value.'

    # Tell DotMailer that you wish to delete the address book
    sample_address_book.delete()
    assert sample_address_book.id is None, 'Address book ID was not ' \
                                           'nulled'

    # Finally, confirm that address book doesn't exists any more
    with pytest.raises(ErrorAddressbookNotFound):
        AddressBook.get_by_id(address_book_id)
Example #2
0
def test_update_valid_address_book(sample_address_book, test_data):
    """
    Test function to confirm that submitting new values to an existing 
    address book, will result in the values on the server being updated.
    
    This test will not work if you are using the demo account creditials.
    :param sample_address_book: 
    :param test_data: 
    :return: 
    """
    address_book_id = _confirm_address_book_valid(sample_address_book)

    # Force an update of the address book
    sample_address_book._update_values(test_data)
    sample_address_book.update()

    # Finally query the server for the address book and confirm the new
    # values where stored.
    address_book = AddressBook.get_by_id(address_book_id)
    for key, value in test_data.items():
        assert getattr(address_book, key) == value