Пример #1
0
    def test_get_active_offer_receipts_success(self):
        cart = self.customer_profile.get_cart_or_checkout_cart()
        offer = Offer.objects.get(pk=3)
        cart.add_offer(offer)

        receipt = Receipt(profile=self.customer_profile,
                          order_item=cart.order_items.first(),
                          start_date=timezone.now(),
                          transaction="123",
                          status=PurchaseStatus.COMPLETE)
        receipt.save()
        self.assertTrue(
            len(self.customer_profile.get_active_offer_receipts(offer)) > 0)
Пример #2
0
    def test_has_previously_owned_products_true(self):
        cart = self.customer_profile.get_cart_or_checkout_cart()
        offer = Offer.objects.get(pk=3)
        cart.add_offer(offer)

        receipt = Receipt(profile=self.customer_profile,
                          order_item=cart.order_items.first(),
                          start_date=timezone.now(),
                          transaction="123",
                          status=PurchaseStatus.COMPLETE)
        receipt.save()
        receipt.products.add(offer.products.first())
        self.assertTrue(
            self.customer_profile.has_previously_owned_products(
                Product.objects.filter(pk=3)))
Пример #3
0
    def test_get_one_time_transaction_receipts(self):
        cart = self.customer_profile.get_cart_or_checkout_cart()
        offer = Offer.objects.get(pk=3)
        cart.add_offer(offer)

        receipt = Receipt(profile=self.customer_profile,
                          order_item=cart.order_items.first(),
                          start_date=timezone.now(),
                          transaction="123",
                          status=PurchaseStatus.COMPLETE)
        receipt.save()
        self.assertEqual(0,
                         len(self.customer_profile.get_recurring_receipts()))
        self.assertEqual(
            1, len(self.customer_profile.get_one_time_transaction_receipts()))