Example #1
0
 def test_user_order_number_with_multiple_orders_but_different_users(self):
     user1 = VokoUserFactory()
     user2 = VokoUserFactory()
     order1 = OrderFactory.create(paid=True, finalized=True, user=user1)
     order2 = OrderFactory.create(paid=True, finalized=True, user=user2)
     self.assertEqual(order1.user_order_number, 1)
     self.assertEqual(order2.user_order_number, 1)
Example #2
0
 def test_total_price_to_pay_with_more_credit_than_order_price(self):
     user = VokoUserFactory()
     BalanceFactory(user=user, type="CR", amount=100)
     order = OrderFactory(user=user)
     OrderProductFactory(order=order, amount=1, product__base_price=10)
     self.assertEqual(
         order.total_price_to_pay_with_balances_taken_into_account(), 0)
Example #3
0
 def test_total_price_to_pay_with_large_debit(self):
     user = VokoUserFactory()
     BalanceFactory(user=user, type="DR", amount=100)
     order = OrderFactory(user=user)
     OrderProductFactory(order=order, amount=1, product__base_price=10)
     self.assertEqual(
         order.total_price_to_pay_with_balances_taken_into_account(),
         order.total_price + Decimal("100"))
Example #4
0
    def test_member_fee_with_one_paid_order(self):
        user = VokoUserFactory()
        order1 = OrderFactory(paid=False, user=user)
        order2 = OrderFactory(paid=True, user=user)
        order3 = OrderFactory(paid=False, user=user)

        self.assertEqual(order1.member_fee, settings.MEMBER_FEE)
        self.assertEqual(order2.member_fee, settings.MEMBER_FEE)
        self.assertEqual(order3.member_fee, Decimal("0"))
Example #5
0
    def test_member_fee_on_unpaid_orders(self):
        user = VokoUserFactory()
        order1 = OrderFactory(paid=False, user=user)
        order2 = OrderFactory(paid=False, user=user)
        order3 = OrderFactory(paid=False, user=user)

        self.assertEqual(order1.member_fee, settings.MEMBER_FEE)
        self.assertEqual(order2.member_fee, settings.MEMBER_FEE)
        self.assertEqual(order3.member_fee, settings.MEMBER_FEE)
Example #6
0
 def test_total_price_to_pay_with_credit(self):
     user = VokoUserFactory()
     BalanceFactory(user=user, type="CR", amount=0.10)
     order = OrderFactory(user=user)
     OrderProductFactory(order=order)
     OrderProductFactory(order=order)
     self.assertEqual(
         order.total_price_to_pay_with_balances_taken_into_account(),
         order.total_price - Decimal("0.10"))
Example #7
0
 def test_user_order_number_with_multiple_orders(self):
     user = VokoUserFactory()
     order1 = OrderFactory.create(paid=True, finalized=True, user=user)
     order2 = OrderFactory.create(paid=False, finalized=True, user=user)
     order3 = OrderFactory.create(paid=True, finalized=True, user=user)
     order4 = OrderFactory.create(paid=True, finalized=False, user=user)
     self.assertEqual(order1.user_order_number, 1)
     self.assertEqual(order2.user_order_number, None)
     self.assertEqual(order3.user_order_number, 2)
     self.assertEqual(order4.user_order_number, None)
Example #8
0
    def login(self, group=None):
        self.user = VokoUserFactory.create()
        self.user.set_password('secret')
        self.user.is_active = True
        self.user.save()

        if group:
            g = Group.objects.create(name=group)
            g.user_set.add(self.user)

        self.client.login(username=self.user.email, password='******')
Example #9
0
    def login(self, group=None):
        self.user = VokoUserFactory.create()
        self.user.set_password('secret')
        self.user.is_active = True
        self.user.save()

        if group:
            g = Group.objects.create(name=group)
            g.user_set.add(self.user)

        self.client.login(username=self.user.email, password='******')
Example #10
0
    def setUp(self):
        self.url = reverse('finance.cancelpayment')

        self.user = VokoUserFactory.create()
        self.user.set_password('secret')
        self.user.is_active = True
        self.user.save()
        self.client.login(username=self.user.email, password='******')

        self.order = OrderFactory(user=self.user,
                                  finalized=True,
                                  paid=False)
Example #11
0
    def setUp(self):
        self.url = reverse("finance.cancelpayment")

        self.user = VokoUserFactory.create()
        self.user.set_password("secret")
        self.user.is_active = True
        self.user.save()
        self.client.login(username=self.user.email, password="******")

        self.order = OrderFactory(user=self.user, finalized=True, paid=False)

        s = self.client.session
        s["order_to_pay"] = self.order.id
        s.save()
Example #12
0
    def setUp(self):
        self.mollie = self.patch("finance.views.Mollie")
        self.mollie_client = self.mollie. \
            API.Client
        self.mollie_client.return_value.issuers.all.return_value = \
            MagicMock()
        self.mollie.API.Object.Method.IDEAL = 'ideal'

        issuers = {"data": [
            {'id': 'EXAMPLE_BANK', 'name': "Example Bank", 'method': 'ideal'},
            {'id': 'ANOTHER_BANK', 'name': "Another Bank", 'method': 'ideal'},
            {'id': 'NON_IDEAL_BANK',
             'name': "Non iDeal Bank",
             'method': 'bla'},
        ]}
        self.mollie_client.return_value.issuers.all.return_value = issuers

        self.user = VokoUserFactory.create()
        self.user.set_password('secret')
        self.user.is_active = True
        self.user.save()
        self.client.login(username=self.user.email, password='******')

        self.mock_create_credit = self.patch(
            "finance.models.Payment.create_and_link_credit")
        self.mock_mail_confirmation = self.patch(
            "ordering.models.Order.mail_confirmation")
        self.mock_failure_notification = self.patch(
            "ordering.models.Order.mail_failure_notification")
        # TODO figure out why this mock breaks all ConfirmTransaction tests
        # self.mock_complete_after_payment = self.patch(
        #     "ordering.models.Order.complete_after_payment")

        class FakePaymentResult(object):
            def __getitem__(self, item):
                if item == "id":
                    return "transaction_id"

            def getPaymentUrl(self):
                return "http://bank.url"

        self.mollie_client.return_value.payments.create.return_value = (
            FakePaymentResult())