예제 #1
0
    def test_correctly_allocates_stock(self):
        factories.create_order(basket=self.basket)

        record = StockRecord.objects.get(product=self.product)
        self.assertEqual(5, record.num_in_stock)
        self.assertEqual(1, record.num_allocated)
        self.assertEqual(4, record.net_stock_level)
예제 #2
0
 def test_downloads_to_csv_without_error(self):
     address = ShippingAddressFactory()
     create_order(shipping_address=address)
     page = self.get(reverse('dashboard:order-list'))
     form = page.forms['orders_form']
     form['selected_order'].checked = True
     form.submit('download_selected')
예제 #3
0
 def test_downloads_to_csv_without_error(self):
     address = get(ShippingAddress)
     create_order(shipping_address=address)
     page = self.get(reverse("dashboard:order-list"))
     form = page.forms["orders_form"]
     form["selected_order"].checked = True
     form.submit("download_selected")
예제 #4
0
    def test_raises_alert_when_threshold_is_reached(self):
        self.set_threshold(5)
        factories.create_order(basket=self.basket)

        alerts = StockAlert.objects.filter(
            stockrecord=self.stockrecord)
        self.assertEqual(1, len(alerts))
 def setUp(self):
     self.order = factories.create_order()
     self.handler = EventHandler()
     basket = factories.create_basket(empty=True)
     add_product(basket, D('10.00'), 5)
     self.order = factories.create_order(basket=basket)
     self.settled = models.PaymentEventType.objects.create(
         name='Settled')
 def setUp(self):
     self.order = create_order()
     self.handler = EventHandler()
     basket = Basket.objects.create()
     basket.add_product(create_product(price=D('10.00')), 5)
     self.order = create_order(basket=basket)
     self.settled = models.PaymentEventType.objects.create(
         name='Settled')
예제 #7
0
    def test_includes_hourly_report_with_orders(self):
        create_order(total_incl_tax=D('34.05'), total_excl_tax=D('34.05'))
        create_order(total_incl_tax=D('21.90'), total_excl_tax=D('21.90'))
        report = IndexView().get_hourly_report()

        self.assertEquals(len(report['order_total_hourly']), 12)
        self.assertEquals(len(report['y_range']), 11)
        self.assertEquals(report['max_revenue'], D('60'))
예제 #8
0
    def test_only_raises_an_alert_once(self):
        self.set_threshold(5)
        StockAlert.objects.create(stockrecord=self.stockrecord,
                                  threshold=10)
        factories.create_order(basket=self.basket)

        alerts = StockAlert.objects.filter(
            stockrecord=self.stockrecord)
        self.assertEqual(1, len(alerts))
 def setUp(self):
     super(UpdateOrderCommandTests, self).setUp()
     self.correct_order = factories.create_order()
     self.affected_order = factories.create_order(number=self.ORDER_NUMBER)
     self.affected_order.total_incl_tax = 98.0
     self.affected_order.total_excl_tax = 98.0
     self.affected_order.save()
     LinePrice.objects.filter(order=self.affected_order).update(quantity=2)
     PaymentEventQuantity.objects.filter(line__in=self.affected_order.lines.all()).update(quantity=2)
     BasketLine.objects.filter(basket=self.affected_order.basket).update(quantity=2)
예제 #10
0
    def test_includes_hourly_report_with_orders(self):
        create_order(total=prices.Price('GBP', excl_tax=D('34.05'),
                                        tax=D('0.00')))
        create_order(total=prices.Price('GBP', excl_tax=D('21.90'),
                                        tax=D('0.00')))
        report = IndexView().get_hourly_report(Order.objects.all())

        self.assertEqual(len(report['order_total_hourly']), 12)
        self.assertEqual(len(report['y_range']), 11)
        self.assertEqual(report['max_revenue'], D('60'))
예제 #11
0
    def test_non_course_order(self):
        """ Refunds should NOT be created for orders with no line items related to courses. """
        Refund.objects.all().delete()
        factories.create_order(user=self.user)
        self.assertEqual(Refund.objects.count(), 0)

        data = self._get_data(self.user.username, self.course_id)
        response = self.client.post(self.path, data, JSON_CONTENT_TYPE)

        self.assert_ok_response(response)
        self.assertEqual(Refund.objects.count(), 0)
예제 #12
0
    def test_with_other_users_orders(self):
        """ The view should only return orders for the authenticated users. """
        other_user = self.create_user()
        factories.create_order(user=other_user)
        response = self.client.get(self.path, HTTP_AUTHORIZATION=self.token)
        self.assert_empty_result_response(response)

        order = factories.create_order(user=self.user)
        response = self.client.get(self.path, HTTP_AUTHORIZATION=self.token)
        content = json.loads(response.content)
        self.assertEqual(content['count'], 1)
        self.assertEqual(content['results'][0]['number'], unicode(order.number))
예제 #13
0
    def setUp(self):
        super(DeleteOrderedBasketsCommandTests, self).setUp()

        # Create baskets with and without orders
        self.orders = [factories.create_order() for __ in range(0, 2)]
        self.unordered_baskets = [factories.BasketFactory() for __ in range(0, 3)]

        # Create invoiced baskets.
        self.invoiced_orders = [factories.create_order() for __ in range(0, 2)]
        self.invoiced_baskets = [order.basket for order in self.invoiced_orders]
        for order in self.invoiced_orders:
            Invoice.objects.create(basket=order.basket, order=order)
    def test_closes_open_alert(self):
        self.set_threshold(5)
        factories.create_order(basket=self.basket)

        alert = StockAlert.objects.get(stockrecord=self.stockrecord)
        self.assertEqual(StockAlert.OPEN, alert.status)

        # Restock product
        self.stockrecord.num_in_stock = 15
        self.stockrecord.save()

        alert = StockAlert.objects.get(stockrecord=self.stockrecord)
        self.assertEqual(StockAlert.CLOSED, alert.status)
예제 #15
0
    def test_username_filter_with_staff(self):
        """ Verify the staff user can filter data by username."""

        # create two orders for different users
        order = factories.create_order(user=self.user)
        other_user = self.create_user()
        other_order = factories.create_order(user=other_user)

        requester = self.create_user(is_staff=True)
        self.client.login(email=requester.email, password=self.password)

        self.assert_list_with_username_filter(self.user, order)
        self.assert_list_with_username_filter(other_user, other_order)
예제 #16
0
    def test_closes_open_alert(self):
        # Set threshold as same as current level
        self.set_threshold(5)
        factories.create_order(basket=self.basket)

        alert = StockAlert.objects.get(stockrecord=self.stockrecord)
        self.assertEqual(StockAlert.OPEN, alert.status)

        # Restock product
        self.stockrecord.num_in_stock = 15
        self.stockrecord.save()

        alert = StockAlert.objects.get(stockrecord=self.stockrecord)
        self.assertEqual(StockAlert.CLOSED, alert.status)
        self.assertIsNotNone(alert.date_closed)
예제 #17
0
 def test_redirects_to_detail_page(self):
     order = create_order()
     page = self.get(reverse('dashboard:order-list'))
     form = page.forms['search_form']
     form['order_number'] = order.number
     response = form.submit()
     self.assertEqual(http_client.FOUND, response.status_code)
예제 #18
0
 def _dummy_order_data(status=ORDER.COMPLETE):
     """ Creates dummy order data for testing."""
     order = create_order()
     order.status = status
     order.save()
     order.basket.freeze()
     return order.basket
예제 #19
0
 def test_gets_404_when_using_incorrect_hash(self):
     order = create_order()
     path = reverse('customer:anon-order',
                    kwargs={'order_number': order.number,
                            'hash': 'bad'})
     response = self.app.get(path, status="*")
     self.assertEqual(http_client.NOT_FOUND, response.status_code)
예제 #20
0
    def test_track_completed_discounted_order_with_voucher_with_offer(self):
        with mock.patch(
                'ecommerce.extensions.checkout.signals.track_segment_event'
        ) as mock_track:
            # Orders may be discounted by a fixed value
            fixed_benefit = 5.00
            offer_discount = 6
            product = ProductFactory(categories=[],
                                     stockrecords__price_currency='USD')
            _range = factories.RangeFactory(products=[product], )
            voucher, product = prepare_voucher(_range=_range,
                                               benefit_value=fixed_benefit,
                                               benefit_type=Benefit.FIXED)
            factories.ConditionalOfferFactory(
                offer_type=ConditionalOffer.SITE,
                benefit=factories.BenefitFactory(range=_range,
                                                 value=offer_discount),
                condition=factories.ConditionFactory(type=Condition.COVERAGE,
                                                     value=1,
                                                     range=_range))

            basket = factories.BasketFactory(owner=self.user, site=self.site)
            basket.add_product(product)
            basket.vouchers.add(voucher)
            Applicator().apply(basket, user=basket.owner, request=self.request)

            order = factories.create_order(basket=basket, user=self.user)
            track_completed_order(None, order)
            properties = self._generate_event_properties(order, voucher)
            mock_track.assert_called_once_with(order.site, order.user,
                                               'Order Completed', properties)
예제 #21
0
    def test_creates_shipments_for_multiple_addresses(self):
        second_address = ShippingAddress.objects.create(
            first_name="test man's friend",
            line1="1 Random Way",
            line4="Spooky Village",
            state="RI",
            postcode="56789",
            country=Country.objects.all()[0],
        )

        addresses = [self.address, second_address]
        order = create_order(basket=self.basket, shipping_address=self.address)
        order.get_fulfillment_addresses = mock.Mock(return_value=addresses)

        def get_lines_for_address(address):
            if address == self.address:
                return order.lines.all()[:1]
            return order.lines.all()[1:]
        order.get_lines_for_address = get_lines_for_address

        mws_orders = self.creator.create_fulfillment_order(order)
        self.assertEquals(FulfillmentOrder.objects.count(), 2)

        for mws_order, address in zip(mws_orders, addresses):
            self.assertEquals(mws_order.status, mws_order.UNSUBMITTED)
            self.assertEquals(mws_order.shipping_address.id, address.id)
예제 #22
0
 def setUp(self):
     Line.pipeline = {'A': ('B', 'C'),
                      'B': ('C',)}
     self.order = create_order()
     self.line = self.order.lines.all()[0]
     self.line.status = 'A'
     self.line.save()
예제 #23
0
 def test_dispatch_order_messages(self):
     email = '*****@*****.**'
     user = User.objects.create_user('testuser', email,
                                     'somesimplepassword')
     order = create_order(number='12345', user=user)
     self.assertFalse(order.is_anonymous)
     self._dispatch_order_messages(order_number='12345', order=order, email=email)
예제 #24
0
    def setUp(self):
        User = get_user_model()
        self.user = User.objects.create_user(
            username='******', email='*****@*****.**', password='******'
        )
        self.product_class = factories.ProductClassFactory(
            name='Seat', requires_shipping=False, track_stock=False
        )
        self.course = factories.ProductFactory(
            structure='parent', upc='001', title='EdX DemoX Course', product_class=self.product_class
        )
        self.seat = factories.ProductFactory(
            structure='child',
            upc='002',
            title='Seat in EdX DemoX Course with Honor Certificate',
            product_class=self.product_class,
            parent=self.course
        )
        for stock_record in self.seat.stockrecords.all():
            stock_record.price_currency = 'USD'
            stock_record.save()

        basket = factories.create_basket(empty=True)
        basket.add_product(self.seat, 1)
        self.order = factories.create_order(number=1, basket=basket, user=self.user)

        # Move the order from 'Open' to 'Paid' so fulfillment can be completed.
        self.order.set_status(ORDER.BEING_PROCESSED)
        self.order.set_status(ORDER.PAID)
예제 #25
0
 def test_can_be_created_with_an_offer(self):
     offer = create_offer()
     order = create_order(number='100002')
     discount = OrderDiscount.objects.create(order=order, amount=D('10.00'),
                                             offer_id=offer.id)
     self.assertEqual(offer.id, discount.offer.id)
     self.assertEqual(offer.name, discount.offer_name)
예제 #26
0
 def test_can_see_order_status(self):
     order = create_order()
     path = reverse('customer:anon-order',
                    kwargs={'order_number': order.number,
                            'hash': order.verification_hash()})
     response = self.app.get(path)
     self.assertEqual(http_client.OK, response.status_code)
예제 #27
0
    def test_track_completed_discounted_order_with_offer(self):
        """ An event including a discount but no coupon should be sent to Segment"""
        with mock.patch(
                'ecommerce.extensions.checkout.signals.track_segment_event'
        ) as mock_track:
            # Orders may be discounted by a fixed value
            offer_discount = 5
            product = ProductFactory(categories=[],
                                     stockrecords__price_currency='USD')
            _range = factories.RangeFactory(products=[product], )
            site_offer = factories.ConditionalOfferFactory(
                offer_type=ConditionalOffer.SITE,
                benefit=factories.BenefitFactory(range=_range,
                                                 value=offer_discount),
                condition=factories.ConditionFactory(type=Condition.COVERAGE,
                                                     value=1,
                                                     range=_range))

            basket = factories.BasketFactory(owner=self.user, site=self.site)
            basket.add_product(product)
            Applicator().apply_offers(basket, [site_offer])

            order = factories.create_order(basket=basket, user=self.user)
            track_completed_order(None, order)
            properties = self._generate_event_properties(order)
            mock_track.assert_called_once_with(order.site, order.user,
                                               'Order Completed', properties)
예제 #28
0
 def test_can_be_created_with_a_voucher(self):
     voucher = create_voucher()
     order = create_order(number='100002')
     discount = OrderDiscount.objects.create(order=order, amount=D('10.00'),
                                             voucher_id=voucher.id)
     self.assertEqual(voucher.id, discount.voucher.id)
     self.assertEqual(voucher.code, discount.voucher_code)
    def test_persist_taxation_details(self, get_transport):
        """Place an order with normal taxes"""
        basket = self.prepare_basket()
        to_address = self.get_to_address()

        resp = self._get_cch_response_normal( basket.all_lines()[0].id )
        get_transport.return_value = self._build_transport_with_reply(resp)

        # This should call CCH and save tax details in the DB
        order = factories.create_order(basket=basket, shipping_address=to_address)

        # Make sure we have an order taxation object
        self.assertEqual(order.taxation.transaction_id, 40043)
        self.assertEqual(order.taxation.transaction_status, 4)
        self.assertEqual(order.taxation.total_tax_applied, D('0.89'))

        # Make sure we have an line taxation objects
        for line in order.lines.all():
            self.assertEqual(line.taxation.country_code, 'US')
            self.assertEqual(line.taxation.state_code, 'NY')
            self.assertEqual(line.taxation.total_tax_applied, D('0.89'))
            self.assertEqual(line.taxation.details.count(), 3)
            for detail in line.taxation.details.all():
                self.assertIn('AuthorityName', detail.data)
                self.assertIn('TaxName', detail.data)
                self.assertIn('TaxRate', detail.data)
                self.assertTrue(float(detail.data['TaxRate']) > 0)
                self.assertIn('TaxableAmount', detail.data)
                self.assertIn('TaxableQuantity', detail.data)
예제 #30
0
    def test_allows_date_placed_to_be_changed_and_set_explicitly(self):
        order = create_order(number='100003')
        tzinfo = timezone.get_current_timezone()
        order.date_placed = datetime(2012, 8, 11, 16, 14, tzinfo=tzinfo)
        order.save()

        self.assertEqual(order.date_placed, datetime(2012, 8, 11, 16, 14, tzinfo=tzinfo))
예제 #31
0
 def setUp(self):
     self.order = create_order()
     self.line = self.order.lines.all()[0]
     self.url = reverse('dashboard:order-line-detail',
                        kwargs={'number': self.order.number,
                                'line_id': self.line.id})
     super(LineDetailTests, self).setUp()
예제 #32
0
    def setUp(self):
        """
        Creates two orders. order_in has self.user in it's partner users list.
        """
        super(PermissionBasedDashboardOrderTestsBase, self).setUp()
        self.address = G(ShippingAddress)
        self.basket_in = create_basket()
        self.basket_out = create_basket()
        # replace partner with one that has the user in it's users list
        self.partner_in = G(Partner, users=[self.user])
        stockrecord = self.basket_in.lines.all()[0].stockrecord
        stockrecord.partner = self.partner_in
        stockrecord.save()

        self.order_in = create_order(basket=self.basket_in, shipping_address=self.address)
        self.order_out = create_order(basket=self.basket_out, shipping_address=self.address)
 def setUp(self):
     super(CouponFulfillmentModuleTest, self).setUp()
     coupon = self.create_coupon()
     user = UserFactory()
     basket = BasketFactory()
     basket.add_product(coupon, 1)
     self.order = factories.create_order(number=1, basket=basket, user=user)
예제 #34
0
 def test_can_be_created_with_a_voucher_and_specidied_voucher_code(self):
     voucher = create_voucher()
     order = create_order(number='100002')
     discount = OrderDiscount.objects.create(order=order, amount=D('10.00'),
                                             voucher_id=voucher.id,
                                             voucher_code="anothercode")
     self.assertEqual(voucher.id, discount.voucher.id)
     self.assertEqual('anothercode', discount.voucher_code)
예제 #35
0
 def setUp(self):
     super(InvoiceCommandTests, self).setUp()
     coupon_pc = factories.ProductClassFactory(name='Coupon')
     self.product = factories.ProductFactory(product_class=coupon_pc)
     self.basket = factories.BasketFactory()
     self.basket.add_product(self.product, 1)
     self.order = factories.create_order(basket=self.basket)
     self.invoice = Invoice.objects.create(order=self.order)
예제 #36
0
    def _create_order(self, price, mode='verified'):
        seat = self.course.create_or_update_seat(mode, False, price, self.partner, None)

        basket = BasketFactory()
        basket.add_product(seat, 1)
        order = create_order(number=1, basket=basket, user=self.user, site=self.site)
        order.total_excl_tax = price
        return seat, order
예제 #37
0
 def test_can_be_created_with_an_offer_and_specified_offer_name(self):
     offer = create_offer(name="My offer")
     order = create_order(number='100002')
     discount = OrderDiscount.objects.create(order=order, amount=D('10.00'),
                                             offer_id=offer.id,
                                             offer_name="Your offer")
     self.assertEqual(offer.id, discount.offer.id)
     self.assertEqual("Your offer", discount.offer_name)
예제 #38
0
 def test_can_be_created_with_a_voucher(self):
     voucher = create_voucher()
     order = create_order(number='100002')
     discount = OrderDiscount.objects.create(order=order,
                                             amount=D('10.00'),
                                             voucher_id=voucher.id)
     self.assertEqual(voucher.id, discount.voucher.id)
     self.assertEqual(voucher.code, discount.voucher_code)
예제 #39
0
    def test_can_be_created_without_offer_or_voucher(self):
        order = create_order(number='100002')
        discount = OrderDiscount.objects.create(order=order, amount=D('10.00'))

        self.assertTrue(discount.voucher is None)
        self.assertTrue(discount.offer is None)

        self.assertEqual(discount.description(), u'')
예제 #40
0
 def test_can_be_created_with_an_offer(self):
     offer = create_offer()
     order = create_order(number='100002')
     discount = OrderDiscount.objects.create(order=order,
                                             amount=D('10.00'),
                                             offer_id=offer.id)
     self.assertEqual(offer.id, discount.offer.id)
     self.assertEqual(offer.name, discount.offer_name)
예제 #41
0
    def test_allows_date_placed_to_be_changed_and_set_explicitly(self):
        order = create_order(number='100003')
        tzinfo = timezone.get_current_timezone()
        order.date_placed = datetime(2012, 8, 11, 16, 14, tzinfo=tzinfo)
        order.save()

        self.assertTupleEqual(self.get_date_tuple(order.date_placed),
                              (2012, 8, 11, 16, 14))
예제 #42
0
 def setUp(self):
     super().setUp()
     # ensures that initial statuses are as expected
     self.order = create_order()
     self.event_type = PaymentEventType.objects.create(name='foo')
     url = reverse('dashboard:order-detail',
                   kwargs={'number': self.order.number})
     self.page = self.get(url)
예제 #43
0
 def test_can_see_order_status(self):
     order = create_order()
     path = reverse('customer:anon-order',
                    kwargs={
                        'order_number': order.number,
                        'hash': order.verification_hash()
                    })
     response = self.app.get(path)
     self.assertEqual(http_client.OK, response.status_code)
예제 #44
0
 def setUp(self):
     basket = create_basket(empty=True)
     add_product(basket, D('10.00'), 4)
     self.order = create_order(number='100002', basket=basket)
     self.line = self.order.lines.all()[0]
     self.order_placed, __ = ShippingEventType.objects.get_or_create(
         code='order_placed', name='Order placed')
     self.dispatched, __ = ShippingEventType.objects.get_or_create(
         code='dispatched', name='Dispatched')
예제 #45
0
    def setUp(self):
        """
        Creates two orders. order_in has self.user in it's partner users list.
        """
        super().setUp()
        self.address = ShippingAddressFactory()
        self.basket_in = create_basket()
        self.basket_out = create_basket()
        # replace partner with one that has the user in it's users list
        self.partner_in = PartnerFactory(users=[self.user])
        stockrecord = self.basket_in.lines.all()[0].stockrecord
        stockrecord.partner = self.partner_in
        stockrecord.save()

        self.order_in = create_order(basket=self.basket_in,
                                     shipping_address=self.address)
        self.order_out = create_order(basket=self.basket_out,
                                      shipping_address=self.address)
예제 #46
0
    def test_set_status_signal_creates_a_order_status_change_object(self):
        self.order = create_order(status='PENDING')
        self.order.set_status('SHIPPED')

        order_status_change = self.order.status_changes.first()

        self.assertEqual(self.order.status_changes.count(), 1)
        self.assertEqual(order_status_change.old_status, 'PENDING')
        self.assertEqual(order_status_change.new_status, 'SHIPPED')
예제 #47
0
 def test_gets_404_when_using_incorrect_hash(self):
     order = create_order()
     path = reverse('customer:anon-order',
                    kwargs={
                        'order_number': order.number,
                        'hash': 'bad'
                    })
     response = self.app.get(path, status="*")
     self.assertEqual(http_client.NOT_FOUND, response.status_code)
예제 #48
0
    def test_staff_superuser(self, is_staff, is_superuser):
        """ The view should return all orders for when authenticating as a staff member or superuser. """
        admin_user = self.create_user(is_staff=is_staff, is_superuser=is_superuser)
        order = factories.create_order(user=self.user)

        response = self.client.get(self.path, HTTP_AUTHORIZATION=self.generate_jwt_token_header(admin_user))
        content = json.loads(response.content)
        self.assertEqual(content['count'], 1)
        self.assertEqual(content['results'][0]['number'], unicode(order.number))
예제 #49
0
    def setUp(self):
        super(TestInvoice, self).setUp()
        self.user = UserFactory()
        self.order = create_order(number='000042', user=self.user)

        LegalEntityAddressFactory(
            legal_entity=LegalEntityFactory(),
            country=CountryFactory(),
        )
예제 #50
0
 def test_dispatch_order_messages(self):
     email = '*****@*****.**'
     user = User.objects.create_user('testuser', email,
                                     'somesimplepassword')
     order = create_order(number='12345', user=user)
     self.assertFalse(order.is_anonymous)
     self._dispatch_order_messages(order_number='12345',
                                   order=order,
                                   email=email)
예제 #51
0
 def test_dispatch_anonymous_order_messages(self):
     order = create_order(number='12346',
                          guest_email='*****@*****.**')
     self.assertTrue(order.is_anonymous)
     self._dispatch_order_messages(
         order_number='12346',
         order=order,
         email='*****@*****.**',
     )
예제 #52
0
    def setUp(self):
        """
        Creates two orders. order_in has self.user in it's partner users list.
        """
        super(PermissionBasedDashboardOrderTestsBase, self).setUp()
        self.address = G(ShippingAddress)
        self.basket_in = create_basket()
        self.basket_out = create_basket()
        # replace partner with one that has the user in it's users list
        self.partner_in = G(Partner, users=[self.user])
        stockrecord = self.basket_in.lines.all()[0].stockrecord
        stockrecord.partner = self.partner_in
        stockrecord.save()

        self.order_in = create_order(basket=self.basket_in,
                                     shipping_address=self.address)
        self.order_out = create_order(basket=self.basket_out,
                                      shipping_address=self.address)
예제 #53
0
 def setUp(self):
     self.order = create_order()
     self.line = self.order.lines.all()[0]
     self.url = reverse('dashboard:order-line-detail',
                        kwargs={
                            'number': self.order.number,
                            'line_id': self.line.id
                        })
     super().setUp()
예제 #54
0
    def test_facade(self):
        request = RequestFactory().get("/api/checkout/")
        order = create_order()
        result = screen_transaction(request, order)

        self.assertEqual(result.screen_type, "Dummy")
        self.assertEqual(result.order, order)
        self.assertEqual(result.decision, "ACCEPT")
        self.assertEqual(result.message, "Transaction accepted.")
예제 #55
0
    def test_facade(self):
        request = RequestFactory().get('/api/checkout/')
        order = create_order()
        result = screen_transaction(request, order)

        self.assertEqual(result.screen_type, 'Dummy')
        self.assertEqual(result.order, order)
        self.assertEqual(result.decision, 'ACCEPT')
        self.assertEqual(result.message, 'Transaction accepted.')
예제 #56
0
    def test_creates_shipments_for_single_address(self):
        order = create_order(basket=self.basket, shipping_address=self.address)
        self.creator.create_fulfillment_order(order)

        mws_orders = FulfillmentOrder.objects.all()
        self.assertEquals(len(mws_orders), 1)
        mws_order = mws_orders[0]
        self.assertEquals(mws_order.status, mws_order.UNSUBMITTED)
        self.assertEquals(mws_order.shipping_address.id, self.address.id)
 def test_str_method_of_invoice_model_instance(self):
     """
     Checks correct representation of `Invoice` instance
     (e.g. in invoices list in the admin site).
     """
     order_number = '0000042'
     order = create_order(number=order_number, user=self.user)
     invoice = InvoiceCreator().create_invoice(order)
     assert str(invoice) == 'Invoice #{} for order #{}'.format(invoice.number, order_number)
    def test_contains_coupon(self):
        self.assertFalse(self.order.contains_coupon)

        product = factories.create_product(
            product_class=COUPON_PRODUCT_CLASS_NAME)
        basket = factories.create_basket(empty=True)
        factories.create_stockrecord(product, num_in_stock=1)
        basket.add_product(product)
        order = factories.create_order(basket=basket)
        self.assertTrue(order.contains_coupon)
예제 #59
0
    def test_with_orders(self):
        """ The view should return a list of the user's orders, sorted reverse chronologically. """
        order = factories.create_order(user=self.user)
        response = self.client.get(self.path, HTTP_AUTHORIZATION=self.token)
        self.assertEqual(response.status_code, 200)
        content = json.loads(response.content)

        self.assertEqual(content['count'], 1)
        self.assertEqual(content['results'][0]['number'], unicode(order.number))

        # Test ordering
        order_2 = factories.create_order(user=self.user)
        response = self.client.get(self.path, HTTP_AUTHORIZATION=self.token)
        self.assertEqual(response.status_code, 200)
        content = json.loads(response.content)

        self.assertEqual(content['count'], 2)
        self.assertEqual(content['results'][0]['number'], unicode(order_2.number))
        self.assertEqual(content['results'][1]['number'], unicode(order.number))
예제 #60
0
    def setUp(self):
        basket = create_basket(empty=True)
        add_product(basket, D('10.00'), 4)
        self.order = create_order(number='100002', basket=basket)
        self.line = self.order.lines.all()[0]

        self.shipped, __ = ShippingEventType.objects.get_or_create(
            name='Shipped')
        self.returned, __ = ShippingEventType.objects.get_or_create(
            name='Returned')