def test_fulfill_order_invalid_module(self, mocked_method): """Verify an exception is logged when an unexpected error occurs.""" mocked_method.return_value = Exception with patch('ecommerce.extensions.fulfillment.api.logger.exception') as mock_logger: api.fulfill_order(self.order, self.order.lines) self.assertEquals(ORDER.FULFILLMENT_ERROR, self.order.status) self.assertTrue(mock_logger.called)
def test_fulfill_order_invalid_module(self, mocked_method): """Verify an exception is logged when an unexpected error occurs.""" mocked_method.return_value = Exception with patch('ecommerce.extensions.fulfillment.api.logger.exception' ) as mock_logger: api.fulfill_order(self.order, self.order.lines) self.assertEqual(ORDER.FULFILLMENT_ERROR, self.order.status) self.assertTrue(mock_logger.called)
def post_checkout_callback(sender, order=None, **kwargs): # pylint: disable=unused-argument # Note (CCB): This is a minor hack to appease coverage. Since this file is loaded before coverage, the imported # module will also be loaded before coverage. Module loaded after coverage are falsely listed as not covered. # We do not want the false report, and we do not want to omit the api module from coverage reports. This is the # "happy" medium. from ecommerce.extensions.fulfillment import api # TODO Determine if we need to create ShippingEvents first. api.fulfill_order(order, order.lines.all())
def handle_shipping_event(self, order, event_type, lines, line_quantities, **kwargs): self.validate_shipping_event(order, event_type, lines, line_quantities, **kwargs) order = fulfillment_api.fulfill_order(order, lines) self.create_shipping_event(order, event_type, lines, line_quantities, **kwargs) return order
def handle_shipping_event(self, order, event_type, lines, line_quantities, **kwargs): self.validate_shipping_event(order, event_type, lines, line_quantities, **kwargs) email_opt_in = kwargs.get('email_opt_in', False) order = fulfillment_api.fulfill_order(order, lines, email_opt_in=email_opt_in) self.create_shipping_event(order, event_type, lines, line_quantities, **kwargs) return order
def test_bad_fulfillment_state(self): """Test a basic fulfillment of a Course Seat.""" # Set the order to Refunded, which cannot be fulfilled. self.order.set_status(ORDER.FULFILLMENT_ERROR) self.order.set_status(ORDER.REFUNDED) fulfillment_api.fulfill_order(self.order, self.order.lines)
def test_fulfill_order_incorrect_module(self): """Test an incorrect Fulfillment Module.""" api.fulfill_order(self.order, self.order.lines) self.assertEqual(ORDER.FULFILLMENT_ERROR, self.order.status) self.assertEqual(LINE.FULFILLMENT_CONFIGURATION_ERROR, self.order.lines.all()[0].status)
def test_fulfill_order_unknown_product_type(self): """Test an unknown product type.""" api.fulfill_order(self.order, self.order.lines) self.assertEqual(ORDER.FULFILLMENT_ERROR, self.order.status) self.assertEqual(LINE.FULFILLMENT_CONFIGURATION_ERROR, self.order.lines.all()[0].status)
def test_fulfill_order_bad_fulfillment_state(self): """Test a basic fulfillment of a Course Seat.""" # Set the order to Complete, which cannot be fulfilled. self.order.set_status(ORDER.COMPLETE) api.fulfill_order(self.order, self.order.lines)
def test_donation_fulfill_order_successful_fulfillment(self): """ Test a successful fulfillment of a donation order. """ order_with_donation = self.generate_open_order( product_class="Donation") api.fulfill_order(order_with_donation, order_with_donation.lines) self.assert_order_fulfilled(order_with_donation)
def test_fulfill_order_successful_fulfillment(self): """ Test a successful fulfillment of an order. """ api.fulfill_order(self.order, self.order.lines) self.assert_order_fulfilled(self.order)
def test_incorrect_module(self): """Test an incorrect Fulfillment Module.""" fulfillment_api.fulfill_order(self.order, self.order.lines) self.assertEquals(ORDER.FULFILLMENT_ERROR, self.order.status) self.assertEquals(LINE.FULFILLMENT_CONFIGURATION_ERROR, self.order.lines.all()[0].status)
def test_fulfill_order_bad_fulfillment_state(self): """Test a basic fulfillment of a Course Seat.""" # Set the order to Complete, which cannot be fulfilled. self.order.set_status(ORDER.COMPLETE) with self.assertRaises(exceptions.IncorrectOrderStatusError): api.fulfill_order(self.order, self.order.lines)
def test_seat_fulfillment(self): """Test a basic fulfillment of a Course Seat.""" fulfillment_api.fulfill_order(self.order, self.order.lines) self.assertEquals(ORDER.COMPLETE, self.order.status) self.assertEquals(LINE.COMPLETE, self.order.lines.all()[0].status)
def test_bad_fulfillment_state(self): """Test a basic fulfillment of a Course Seat.""" # Set the order to Refunded, which cannot be fulfilled. self.order.set_status(ORDER.COMPLETE) api.fulfill_order(self.order, self.order.lines)
def test_successful_fulfillment(self): """ Test a successful fulfillment of an order. """ api.fulfill_order(self.order, self.order.lines) self.assert_order_fulfilled(self.order)
def test_fulfill_order_unknown_product_type(self): """Test an unknown product type.""" api.fulfill_order(self.order, self.order.lines) self.assertEquals(ORDER.FULFILLMENT_ERROR, self.order.status) self.assertEquals(LINE.FULFILLMENT_CONFIGURATION_ERROR, self.order.lines.all()[0].status)