コード例 #1
0
def test_save_multiple_delivery_address():
    profile = Profile()
    addresses = [Address('100 John Rd', 'Toronto', 'ON', 'M5R 7U6'),
                 Address('200 Mark Blvd', 'Mississauga', 'ON', 'L5M 1Y1')]
    profile.add_adresses(addresses)

    assert len(profile.addresses) == 2, "The profile should now have two addresses"
コード例 #2
0
def test_add_order_history():
    profile = Profile()
    assert len(profile.order_history) == 0, "Order history should be empty"

    history1 = History('Salad', 'delivered', datetime.datetime(2020, 5, 17))
    history2 = History('Burger', 'cancelled', datetime.datetime(2020, 5, 18))

    profile.add_order_history(history1)
    profile.add_order_history(history2)

    assert len(profile.order_history) == 2, "Order history should contain the items that were ordered"
コード例 #3
0
def test_modify_profile():
    profile = Profile()
    account = Account('Shivam', 'shars48', 'password', profile)
    account.set_email('*****@*****.**')
    assert account.email == '*****@*****.**', "The current email should be returned"
    account.set_email('*****@*****.**')
    assert account.email == "*****@*****.**", "The updated email should be returned"
コード例 #4
0
def test_add_payment_info_to_account():
    profile = Profile()
    payment_info = PaymentInfo('VISA', '0000-1111-2222-3333')
    profile.add_payment_info(payment_info)

    assert profile.payment_info.details == '0000-1111-2222-3333', "The saved payment info should be correct"
コード例 #5
0
def test_check_order_status():
    history = History('Salad', 'delivered', datetime.datetime(2020, 5, 17))
    profile = Profile()
    profile.add_order_history(history)
    assert profile.order_history[0].order_status == 'delivered', "Should be able to check order status from history"
コード例 #6
0
def test_invalid_login():
    profile = Profile()
    account = Account('Shivam', 'shars48', 'password', profile)
    assert account.authenticate('shars48', 'pass') is False, "Valid credentials should allow login"
コード例 #7
0
def test_invalid_email_verification():
    profile = Profile()
    account = Account('Shivam', 'shars48', 'password', profile)
    account.set_email('shivam-xyz.com')
    assert account.email != 'shivam-xyz.com', "Invalid email should not be added"
コード例 #8
0
def test_apply_invalid_discount_coupon():
    coupon = DiscountCoupon('15% off', datetime.datetime(2020, 10, 30))
    profile = Profile()
    profile.add_discount_coupon(coupon)
    assert len(profile.discount_coupon) == 0, "Should not be able to add invalid coupon"
コード例 #9
0
def test_profile_creation():
    profile = Profile()
    account = Account('Shivam', 'shars48', 'password', profile)
    account.set_email('*****@*****.**')

    assert account.name == 'Shivam' and account.email == '*****@*****.**' and account.password == 'password' and account.username == 'shars48', "Account should be created"
コード例 #10
0
def test_delete_account():
    profile = Profile()
    account = Account('Shivam', 'shars48', 'password', profile)
    account.delete_account()
    assert account.authenticate('shars48', 'password') is False, "Should not be able to authenticate after account " \
                                                                 "has been deleted"