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'])
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(source_account=account) editor = InPaymentEditor(self.store, payment) self.check_editor(editor, 'editor-paid-in-payment-edit')
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')
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)
def test_value_validation(self): editor = InPaymentEditor(self.store) self.assertEqual(str(editor.value.emit('validate', None)), u"The value must be greater than zero.") self.assertEqual(str(editor.value.emit('validate', -1)), u"The value must be greater than zero.") self.assertFalse(editor.value.emit('validate', 10))
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)
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)
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'])
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.assertEqual(editor.model.payment_type, Payment.TYPE_IN) self.assertEqual(editor.model.method.method_name, u'money') self.assertEqual(editor.model.description, u'') self.assertEqual(editor.model.status, Payment.STATUS_PENDING) self.assertEqual(editor.model.value, 0) self.assertEqual(editor.model.category, None) self.check_editor(editor, 'editor-in-payment-create')
def test_show_sale_dialog(self, run_dialog): sale = self.create_sale() self.add_product(sale) sale.order(self.current_user) self.add_payments(sale, method_type=u'money') sale.confirm(self.current_user) 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 stoq.lib.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.assertEqual(run_dialog.call_count, 1)
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')