def test_email_receipt_after_order_fails(): # 4.5 Email Receipt after Order manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert emailUtils.send_receipt( account.email_address, {}) == False, 'No Receipt Found, Email has not been sent'
def test_verify_password_reset_email_exists(): # 4.2.1.1 Email validation manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert manager.verify_email_does_not_exist_in_system( account.email_address) == True, 'Email should exist in the system'
def test_send_password_reset_email_is_successful(): # 4.2.1.2 Password reset email manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert manager.send_password_reset_email( account.email_address) == True, 'Password reset email should be sent successfully'
def test_user_does_not_have_account(): # 4.4 Existing and Guest User Receipt manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert emailUtils.account_exist( '*****@*****.**') == True, 'Account does exist'
def test_get_customer_information(): # 4.6.1 Customer Information manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert emailUtils.get_account( account) == True, 'Account information found'
def test_email_is_found(): # 4.5.1.2 Email is found manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert emailUtils.get_customer_information( '*****@*****.**') == True, 'Customer information found'
def test_verify_existing_account_with_existing_account(): # 4.1.1.2 Existing accounts email = '*****@*****.**' manager = AccountManager() newAccount = Account(email) manager.add_account(newAccount) assert manager.verify_email_does_not_exist_in_system( email) == False, 'Account already exists within the system'
def test_password_verification_link_contains_correct_link(): # 4.1.3.1 Password verification link manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) email_details = manager.send_email_verification_email(account) assert email_details != None and email_details.contains_correct_link() == True, 'Email verification email should contain a correct link'
def test_account_ban_successful(): # 4.8.2 Account banning manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) manager.ban_account(account, True) assert manager.is_account_banned(account) == True, 'Expected account to be banned'
def test_customer_view_all_accounts_unsuccessful(): # 4.8.1 Account view access manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) account_data = manager.view_all_accounts('Customer') assert len(account_data) == 0, 'Expected to successfully retrieve all account data'
def test_kitchen_manager_view_all_accounts_success(): # 4.8.1 Account view access manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) account_data = manager.view_all_accounts('KitchenManager') assert account_data[0].email_address == account.email_address, 'Expected to successfully retrieve all account data'
def test_can_view_specific_account_data_success(): # 4.7.1.1 Viewable Customer Information manager = AccountManager() account = Account('*****@*****.**') manager.add_account(account) assert accountManger.get_account( account) == True, 'Account information found'
def test_account_activation_link_is_not_valid(): # 4.1.3.3 Account activation - Invalid link & 4.1.3.2 Link verification account = Account('*****@*****.**') manager = AccountManager() account.activation_code = 'Test34' manager.add_account(account) assert manager.unlock_account( 'invalidCode') == False, 'Account should not be unlocked'
def test_account_activation_link_is_valid(): # 4.1.3.4 Account activation & 4.1.3.2 Link verification account = Account('*****@*****.**') manager = AccountManager() account.activation_code = 'Test123' manager.add_account(account) assert manager.unlock_account( account.activation_code) == True, 'Account should successfully be unlocked'
def test_account_unban_successful(): # 4.8.2 Account banning manager = AccountManager() account = Account('*****@*****.**') account.is_banned = True manager.add_account(account) manager.ban_account(account, False) assert manager.is_account_banned(account) == False, 'Expected account to be not banned'
def test_invalid_payment_address(): # 4.5.1.4 Payment Address Validation manager = AccountManager() account = Account('*****@*****.**') account.address = '10 invalid 10 drive' manager.add_account(account) assert emailUtils.validate_payment_address( account.address) == True, 'Payment Address is invalid'
def test_invalid_shipping_address(): # 4.5.1.3 Shipping Address Validation manager = AccountManager() account = Account('*****@*****.**') account.address = '10 not valid 10 drive' manager.add_account(account) assert emailUtils.validate_shipping_address( account.address) == False, 'Shipping Address is invalid'
def test_valid_shipping_address(): # 4.5.1.3 Shipping Address Validation manager = AccountManager() account = Account('*****@*****.**') account.address = '10 valid drive' manager.add_account(account) assert emailUtils.validate_shipping_address( account.address) == True, 'Shipping Address is valid'
def test_customer_can_view_account(): # 4.7.1 Personal Account Information manager = AccountManager() account = Account('*****@*****.**') account.address = 'address' account.payment_method = 'visa' manager.add_account(account) assert accountManger.get_account(account) == True, 'Account found'
def test_login_account_with_correct_information_success(): # 4.3.5 Login success manager = AccountManager() account = Account('*****@*****.**') account.password = '******' account.is_locked = False manager.add_account(account) assert manager.login(account.email_address, account.password) == True, 'Expected login to succeed'
def test_payment_detail_saved_for_guest_account(): # 4.6.2 Complete Sale Transaction Details for Guest Account manager = AccountManager() account = Account('*****@*****.**') account.address = 'address' account.payment_method = 'visa' manager.add_account(account) assert emailUtils.save_order( account) == True, 'Payment Information has been saved'
def test_reset_password_is_successful(): # 4.2 Password Reset account = Account('*****@*****.**') account.password = '******' manager = AccountManager() manager.add_account(account) manager.change_password(account, 'newPassword454') assert manager.change_password( account, 'newPassword454') == True, 'Account password should be successfully changed'
def test_modify_account_information(): # 4.7.2.1 Modifiable Information manager = AccountManager() account = Account('*****@*****.**') account.first_name = 'John' account.last_name = 'Doe' account.address = '10 Valid Drive' manager.add_account(account) assert manager.change_personal_information( account, 'Joe', 'Schmoe', '*****@*****.**', '10 Change Lane') == True, 'Account information successfully changed'
def test_login_password_is_incorrect_fails(): # 4.3.2 Password is incorrect manager = AccountManager() account = Account('*****@*****.**') account.password = '******' account.is_locked = False account.is_banned = False manager.add_account(account) with pytest.raises(AccountIncorrectPasswordException): assert manager.login( account.email_address, 'wrongPassword2'), 'Expected login to fail due to incorrect password'
def test_login_account_is_banned_fails(): # 4.3.4 Account is banned manager = AccountManager() account = Account('*****@*****.**') account.password = '******' account.is_locked = False account.is_banned = True manager.add_account(account) with pytest.raises(AccountBannedException): assert manager.login( account.email_address, account.password), 'Expected login to fail due to banned account'
def test_email_has_link_to_account_creation_page(): # 4.4.1.1 Guest Account Creation manager = AccountManager() account = Account('*****@*****.**') staff_account = Account('*****@*****.**') manager.add_account(account) manager.add_account(staff_account) new_order = Order(account, staff_account) order_receipt = Receipt(new_order) assert emailUtils.validate_receipt_content( order_receipt) == True, 'Redirect Link Found'
def test_complete_sale_transaction_details_for_guest_account(): # 4.6.3 Complete Sale Transaction Details for Guest Account manager = AccountManager() account = Account('*****@*****.**') account.address = 'address' account.payment_method = 'visa' staff_account = Account('*****@*****.**') manager.add_account(account) manager.add_account(staff_account) new_order = Order(account, staff_account) assert emailUtils.save_order( new_order) == True, 'Transaction Information has been saved'
def test_view_customer_orders(): # 4.7.3.1 Order Information orderManager = OrderManager() manager = AccountManager() account = Account('*****@*****.**') staff_account = Account('*****@*****.**') manager.add_account(account) manager.add_account(staff_account) new_order = Order(account, staff_account) orderManager.add_order(new_order) all_orders = orderManager.view_all_orders(account) assert all_orders[0].customer == account, 'Orders found'
def test_send_receipt_to_existing_account(): # 4.4.2 Existing User Receipt manager = AccountManager() account = Account('*****@*****.**') staff_account = Account('*****@*****.**') manager.add_account(account) manager.add_account(staff_account) assert emailUtils.account_exist( '*****@*****.**') == True, 'Account does exist' new_order = Order(account, staff_account) order_receipt = Receipt(new_order) assert emailUtils.send_receipt( '*****@*****.**', order_receipt) == True, 'Email has been sent'
def test_send_receipt_to_guest(): # 4.4.1 Guest User Receipt manager = AccountManager() account = Account('*****@*****.**') staff_account = Account('*****@*****.**') manager.add_account(account) manager.add_account(staff_account) new_order = Order(account, staff_account) order_receipt = Receipt(new_order) assert emailUtils.account_exist( account) == False, 'Account does not exist' assert emailUtils.send_receipt( '*****@*****.**', order_receipt) == True, 'Email has been sent'