def test_pay_order_with_subscription(self): expected_mail = Mail( address='*****@*****.**', subject='24/7 sl terminal show subscription', body= ('Hello Ofelia\n' 'You have been subscribed to "24/7 sl terminal show" for 12 months\n' )) customer = Customer('Ofelia', '*****@*****.**') credit_card = CreditCard.fetch_by_hashed('01234-4321') order = Order(customer, Address('42100')) order.add_product(Product('24/7 sl terminal show', ProductType.MEMBERSHIP, price=20), quantity=12) order_service.pay(order, credit_card) assert expected_mail in EmailClient.queue assert '24/7 sl terminal show' in Subscriptions.by_customer(customer)
def test_it_orders_a_service_subscription_item(self): expected_mail = Mail( address='*****@*****.**', subject='Netflix subscription', body=( 'Hello Cuenta Puertas\n' 'You have been subscribed to "Netflix" for 2 months\n' ) ) customer = Customer('Cuenta Puertas', email='*****@*****.**') credit_card = CreditCard.fetch_by_hashed('43567890-987654367') item = Product(name='Netflix', type=ProductType.MEMBERSHIP, price=15.0) order = Order(customer, Address('46100')) order.add_product(item, 2) order_service.pay(order, payment_method=credit_card) assert order.is_paid assert order.customer == customer assert order.items[0].product == item assert order.payment.amount == 30.0 assert expected_mail in EmailClient.queue assert 'Netflix' in Subscriptions.by_customer(customer)