Example #1
0
 def test_end_date_sensitivity(self):
     editor = InPaymentEditor(self.store)
     self.assertNotSensitive(editor, ['end_date'])
     editor.repeat.update(INTERVALTYPE_WEEK)
     self.assertSensitive(editor, ['end_date'])
     editor.repeat.update(-1)
     self.assertNotSensitive(editor, ['end_date'])
Example #2
0
 def test_edit__paid_in_payment(self):
     payment = self.create_payment(payment_type=Payment.TYPE_IN)
     payment.status = Payment.STATUS_PENDING
     account = self.store.find(Account, description=u'Expenses').one()
     payment.pay(account=account)
     editor = InPaymentEditor(self.store, payment)
     self.check_editor(editor, 'editor-paid-in-payment-edit')
Example #3
0
    def test_create_category(self):
        category = PaymentCategory(store=self.store,
                                   name=u'TestCategory',
                                   category_type=PaymentCategory.TYPE_RECEIVABLE)
        editor = InPaymentEditor(self.store, category=category.name)

        self.check_editor(editor, 'editor-in-payment-create-with-category')
Example #4
0
    def test_show_lonely_dialog_in(self, run_dialog):
        payment = self.create_payment(payment_type=Payment.TYPE_IN)
        payment.group = self.create_payment_group()
        editor = InPaymentEditor(self.store, payment)

        self.click(editor.details_button)
        run_dialog.assert_called_once_with(LonelyPaymentDetailsDialog, editor,
                                           editor.store, editor.model)
Example #5
0
    def test_value_validation(self):
        editor = InPaymentEditor(self.store)
        self.assertEquals(unicode(editor.value.emit('validate', None)),
                          u"The value must be greater than zero.")

        self.assertEquals(unicode(editor.value.emit('validate', -1)),
                          u"The value must be greater than zero.")
        self.assertFalse(editor.value.emit('validate', 10))
Example #6
0
    def test_show_stock_decrease_dialog(self, run_dialog):
        group = self.create_payment_group()
        decrease = self.create_stock_decrease(group=group)
        self.create_stock_decrease_item(decrease)
        self.add_payments(decrease)
        payment = decrease.group.payments[0]

        editor = InPaymentEditor(self.store, payment)
        self.click(editor.details_button)
        run_dialog.assert_called_once_with(StockDecreaseDetailsDialog, editor,
                                           self.store, decrease)
Example #7
0
    def test_show_from_sale(self):
        sale = self.create_sale()
        sale.identifier = 12345
        self.add_payments(sale, method_type=u'money')

        p = sale.payments[0]

        editor = InPaymentEditor(self.store, p)
        self.check_editor(editor, 'editor-in-payment-show-sale')

        self.assertTrue(editor.model.group.sale)
Example #8
0
    def test_repeat_validation(self):
        editor = InPaymentEditor(self.store)
        editor.description.update(u'desc')
        editor.value.update(Decimal('10'))
        editor.due_date.update(localtoday().date())

        editor.repeat.update(INTERVALTYPE_WEEK)
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])

        editor.repeat.update(_ONCE)
        self.assertSensitive(editor.main_dialog, ['ok_button'])
Example #9
0
    def test_create(self):
        editor = InPaymentEditor(self.store)

        # Model
        self.assertTrue(isinstance(editor.model, Payment))
        # FIXME: In the long run this should be moved into the domain,
        #        Like Domain.create_empty() or so
        self.assertEquals(editor.model.payment_type, Payment.TYPE_IN)
        self.assertEquals(editor.model.method.method_name, u'money')
        self.assertEquals(editor.model.description, u'')
        self.assertEquals(editor.model.status, Payment.STATUS_PENDING)
        self.assertEquals(editor.model.value, 0)
        self.assertEquals(editor.model.category, None)
        self.check_editor(editor, 'editor-in-payment-create')
Example #10
0
    def test_show_sale_dialog(self, run_dialog):
        sale = self.create_sale()
        self.add_product(sale)
        sale.order()
        self.add_payments(sale, method_type=u'money')
        sale.confirm()

        p = sale.payments[0]

        editor = InPaymentEditor(self.store, p)

        self.click(editor.details_button)
        # FIXME: for Viewable comparision in Storm"
        # from stoqlib.domain.sale import SaleView
        # from stoqlib.gui.dialogs.saledetails import SaleDetailsDialog
        # sale_view = SaleView.get(editor.model.group.sale.id, store=self.store)
        # run_dialog.assert_called_once_with(SaleDetailsDialog, editor,
        #                                   editor.store, sale_view)
        self.assertEquals(run_dialog.call_count, 1)
Example #11
0
    def test_show_in(self):
        payment = self.create_payment(payment_type=Payment.TYPE_IN)
        payment.group = self.create_payment_group()
        editor = InPaymentEditor(self.store, payment)

        self.check_editor(editor, 'editor-in-payment-show')