Beispiel #1
0
    def test_installment_limits(self):
        card_method = self.store.find(PaymentMethod, method_name=u'card').one()
        card_method.max_installments = 16

        device = self.create_card_device()
        provider = self.create_credit_provider()
        cost = self.create_operation_cost(device=device,
                                          provider=provider,
                                          start=2,
                                          end=5)
        editor = CardOperationCostEditor(self.store, cost, cost.device)

        editor.card_type.update(CreditCardData.TYPE_CREDIT)

        upper_start = editor.installment_start.get_adjustment().get_upper()
        upper_end = editor.installment_end.get_adjustment().get_upper()

        self.assertEquals(upper_start, 1)
        self.assertEquals(upper_end, 1)

        editor.card_type.update(CreditCardData.TYPE_CREDIT_INSTALLMENTS_STORE)

        upper_start = editor.installment_start.get_adjustment().get_upper()
        upper_end = editor.installment_end.get_adjustment().get_upper()

        self.assertEquals(upper_start, 16)
        self.assertEquals(upper_end, 16)
Beispiel #2
0
    def test_validation(self):
        device = self.create_card_device()
        provider = self.create_credit_provider()
        # Create another cost to test validation
        self.create_operation_cost(
            device=device,
            provider=provider,
            start=4,
            end=6,
            card_type=CreditCardData.TYPE_CREDIT_INSTALLMENTS_STORE)

        cost = self.create_operation_cost(
            device=device,
            provider=provider,
            card_type=CreditCardData.TYPE_CREDIT_INSTALLMENTS_STORE)
        editor = CardOperationCostEditor(self.store, cost, cost.device)

        self.assertValid(editor, ['installment_start', 'installment_end'])

        # Range [1, 3] is invalid
        editor.installment_start.set_text('3')
        editor.installment_end.set_text('1')
        self.assertInvalid(editor, ['installment_start', 'installment_end'])

        editor.installment_start.set_text('1')
        editor.installment_end.set_text('3')
        self.assertValid(editor, ['installment_start', 'installment_end'])

        editor.installment_start.set_text('1')
        editor.installment_end.set_text('4')
        self.assertInvalid(editor, ['installment_start', 'installment_end'])

        editor.installment_start.set_text('7')
        editor.installment_end.set_text('8')
        self.assertValid(editor, ['installment_start', 'installment_end'])

        editor.fee.set_text('10')
        self.click(editor.main_dialog.ok_button)

        self.assertEquals(cost.fee, 10)
        self.assertEquals(cost.installment_start, 7)
        self.assertEquals(cost.installment_end, 8)
Beispiel #3
0
 def test_show(self):
     cost = self.create_operation_cost()
     device = cost.device
     editor = CardOperationCostEditor(self.store, cost, device)
     self.check_editor(editor, 'editor-cardoperationcosteditor-show')
Beispiel #4
0
 def test_create(self):
     device = self.create_card_device()
     editor = CardOperationCostEditor(self.store, None, device)
     self.check_editor(editor, 'editor-cardoperationcosteditor-create')