Exemplo n.º 1
0
    def test_credit_editor(self):
        client = self.create_client()
        self.assertEquals(client.credit_account_balance, 0)

        editor = CreditEditor(self.store, client)
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])
        self.check_editor(editor, 'editor-client-credit')

        editor.description.set_text('Desc')
        editor.value.set_text('4')
        self.assertSensitive(editor.main_dialog, ['ok_button'])
        editor.confirm()
        self.assertEquals(client.credit_account_balance, 4)

        editor = CreditEditor(self.store, client)
        editor.description.set_text('Desc 2')
        editor.value.set_text('-3')
        # We need the payment generated by the editor to perform some tests. We
        # won't confirm the dialog to avoid creating repeated payments.
        payment = editor._create_payment()

        self.assertEquals(payment.value, currency(3))
        self.assertEquals(payment.payment_type, Payment.TYPE_IN)
        self.assertEquals(client.credit_account_balance, 1)
Exemplo n.º 2
0
    def test_credit_editor(self):
        client = self.create_client()
        self.assertEqual(client.credit_account_balance, 0)

        editor = CreditEditor(self.store, client)
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])
        self.check_editor(editor, 'editor-client-credit')

        editor.description.set_text('Desc')
        editor.value.set_text('4')
        self.assertSensitive(editor.main_dialog, ['ok_button'])
        editor.confirm()
        self.assertEqual(client.credit_account_balance, 4)

        editor = CreditEditor(self.store, client)
        editor.description.set_text('Desc 2')
        editor.value.set_text('-3')
        # We need the payment generated by the editor to perform some tests. We
        # won't confirm the dialog to avoid creating repeated payments.
        payment = editor._create_payment()

        self.assertEqual(payment.value, currency(3))
        self.assertEqual(payment.payment_type, Payment.TYPE_IN)
        self.assertEqual(client.credit_account_balance, 1)