예제 #1
0
    def setUp(self):
        payment = self.create_payment(value=Decimal('8280'),
                                      date=datetime.date(2011, 2, 5))
        bank = self.create_bank_account(
            bank_branch=u'278-0',
            bank_account=u'039232-4',
        )
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'2125525')
        payment.method.destination_account.bank = bank
        self.dados = BankBradesco(payment)

        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(
            bank_branch=u'1172',
            bank_account=u'403005',
        )
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        self.dados2 = BankBradesco(payment)
예제 #2
0
    def testCarteira(self):
        x = BankBradesco(
            carteira=u'9',
            agencia=u'02752',
            conta=u'14978-0',
            data_vencimento=datetime.date(2011, 3, 9),
            valor_documento=2952.95,
            nosso_numero=u'75896452',
            numero_documento=u'75896452')
        self.assertEquals(
            x.barcode, '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', 'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '100')
예제 #3
0
    def setUp(self):
        self.dados = BankBradesco(
            carteira=u'06',
            agencia=u'278-0',
            conta=u'039232-4',
            data_vencimento=datetime.date(2011, 2, 5),
            valor_documento=8280.00,
            nosso_numero=u'2125525',
        )

        self.dados2 = BankBradesco(
            carteira=u'06',
            agencia=u'1172',
            conta=u'403005',
            data_vencimento=datetime.date(2011, 3, 9),
            valor_documento=2952.95,
            nosso_numero=u'75896452',
            numero_documento=u'75896452',
        )
예제 #4
0
    def test_carteira(self):
        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(bank_branch=u'02752',
                                        bank_account=u'14978-0',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'9')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        x = BankBradesco(payment)
        self.assertEqual(
            x.barcode, '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', 'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '100')
예제 #5
0
    def test_carteira(self):
        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(
            bank_branch=u'02752',
            bank_account=u'14978-0',
        )
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'9')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        x = BankBradesco(payment)
        self.assertEquals(x.barcode,
                          '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          '100')
예제 #6
0
    def setUp(self):
        self.dados = BankBradesco(
            carteira=u'06',
            agencia=u'278-0',
            conta=u'039232-4',
            data_vencimento=datetime.date(2011, 2, 5),
            valor_documento=8280.00,
            nosso_numero=u'2125525',
        )

        self.dados2 = BankBradesco(
            carteira=u'06',
            agencia=u'1172',
            conta=u'403005',
            data_vencimento=datetime.date(2011, 3, 9),
            valor_documento=2952.95,
            nosso_numero=u'75896452',
            numero_documento=u'75896452',
        )
예제 #7
0
    def setUp(self):
        payment = self.create_payment(value=Decimal('8280'),
                                      date=datetime.date(2011, 2, 5))
        bank = self.create_bank_account(bank_branch=u'278-0',
                                        bank_account=u'039232-4',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'2125525')
        payment.method.destination_account.bank = bank
        self.dados = BankBradesco(payment)

        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(bank_branch=u'1172',
                                        bank_account=u'403005',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        self.dados2 = BankBradesco(payment)
예제 #8
0
    def test_carteira(self):
        x = BankBradesco(carteira=u'9',
                         agencia=u'02752',
                         conta=u'14978-0',
                         data_vencimento=datetime.date(2011, 3, 9),
                         valor_documento=2952.95,
                         nosso_numero=u'75896452',
                         numero_documento=u'75896452')
        self.assertEquals(x.barcode,
                          '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          '100')
예제 #9
0
class TestBancoBradesco(DomainTest):
    def setUp(self):
        payment = self.create_payment(value=Decimal('8280'),
                                      date=datetime.date(2011, 2, 5))
        bank = self.create_bank_account(bank_branch=u'278-0',
                                        bank_account=u'039232-4',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'2125525')
        payment.method.destination_account.bank = bank
        self.dados = BankBradesco(payment)

        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(bank_branch=u'1172',
                                        bank_account=u'403005',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        self.dados2 = BankBradesco(payment)

    def test_linha_digitavel(self):
        self.assertEqual(self.dados.linha_digitavel,
                         '23790.27804 60000.212559 25003.923205 4 48690000828000'
                         )

        self.assertEqual(self.dados2.linha_digitavel,
                         '23791.17209 60007.589645 52040.300502 1 49010000295295'
                         )

    def test_codigo_de_barras(self):
        self.assertEqual(self.dados.barcode,
                         '23794486900008280000278060000212552500392320'
                         )
        self.assertEqual(self.dados2.barcode,
                         '23791490100002952951172060007589645204030050'
                         )

    def test_agencia(self):
        self.assertEqual(self.dados.agencia, '0278-0')

    def test_conta(self):
        self.assertEqual(self.dados.conta, '0039232-4')

    def test_validate_field(self):
        valid = ['0278-0',
                 '1172',
                 '14978-0',
                 '403005',
                 '0039232-4',
                 '02752']
        for v in valid:
            self.dados.validate_field(v)

    def test_dv_nosso_numero(self):
        self.dados.nosso_numero = '1236'
        self.assertEqual(self.dados.dv_nosso_numero, 'P')

        self.dados.nosso_numero = '1244'
        self.assertEqual(self.dados.dv_nosso_numero, 0)

    def test_carteira(self):
        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(bank_branch=u'02752',
                                        bank_account=u'14978-0',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'9')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        x = BankBradesco(payment)
        self.assertEqual(
            x.barcode, '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', 'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '100')
예제 #10
0
class TestBancoBradesco(unittest.TestCase):
    def setUp(self):
        self.dados = BankBradesco(
            carteira=u'06',
            agencia=u'278-0',
            conta=u'039232-4',
            especie_documento=u'DM',
            data_vencimento=datetime.date(2011, 2, 5),
            valor_documento=8280.00,
            nosso_numero=u'2125525',
        )

        self.dados2 = BankBradesco(
            carteira=u'06',
            agencia=u'1172',
            conta=u'403005',
            especie_documento=u'DM',
            data_vencimento=datetime.date(2011, 3, 9),
            valor_documento=2952.95,
            nosso_numero=u'75896452',
            numero_documento=u'75896452',
        )

    def test_linha_digitavel(self):
        self.assertEqual(
            self.dados.linha_digitavel,
            '23790.27804 60000.212559 25003.923205 4 48690000828000')

        self.assertEqual(
            self.dados2.linha_digitavel,
            '23791.17209 60007.589645 52040.300502 1 49010000295295')

    def test_codigo_de_barras(self):
        self.assertEqual(self.dados.barcode,
                         '23794486900008280000278060000212552500392320')
        self.assertEqual(self.dados2.barcode,
                         '23791490100002952951172060007589645204030050')

    def test_agencia(self):
        self.assertEqual(self.dados.agencia, '0278-0')

    def test_conta(self):
        self.assertEqual(self.dados.conta, '0039232-4')

    def test_validate_field(self):
        valid = ['0278-0', '1172', '14978-0', '403005', '0039232-4', '02752']
        for v in valid:
            self.dados.validate_field(v)

    def test_carteira(self):
        x = BankBradesco(carteira=u'9',
                         agencia=u'02752',
                         conta=u'14978-0',
                         data_vencimento=datetime.date(2011, 3, 9),
                         valor_documento=2952.95,
                         nosso_numero=u'75896452',
                         numero_documento=u'75896452')
        self.assertEquals(x.barcode,
                          '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira',
                          '100')
예제 #11
0
class TestBancoBradesco(unittest.TestCase):
    def setUp(self):
        self.dados = BankBradesco(
            carteira=u'06',
            agencia=u'278-0',
            conta=u'039232-4',
            data_vencimento=datetime.date(2011, 2, 5),
            valor_documento=8280.00,
            nosso_numero=u'2125525',
        )

        self.dados2 = BankBradesco(
            carteira=u'06',
            agencia=u'1172',
            conta=u'403005',
            data_vencimento=datetime.date(2011, 3, 9),
            valor_documento=2952.95,
            nosso_numero=u'75896452',
            numero_documento=u'75896452',
        )

    def test_linha_digitavel(self):
        self.assertEqual(self.dados.linha_digitavel,
                         '23790.27804 60000.212559 25003.923205 4 48690000828000'
                         )

        self.assertEqual(self.dados2.linha_digitavel,
                         '23791.17209 60007.589645 52040.300502 1 49010000295295'
                         )

    def test_codigo_de_barras(self):
        self.assertEqual(self.dados.barcode,
                         '23794486900008280000278060000212552500392320'
                         )
        self.assertEqual(self.dados2.barcode,
                         '23791490100002952951172060007589645204030050'
                         )

    def test_agencia(self):
        self.assertEqual(self.dados.agencia, '0278-0')

    def test_conta(self):
        self.assertEqual(self.dados.conta, '0039232-4')

    def test_validate_field(self):
        valid = ['0278-0',
                 '1172',
                 '14978-0',
                 '403005',
                 '0039232-4',
                 '02752']
        for v in valid:
            self.dados.validate_field(v)

    def testCarteira(self):
        x = BankBradesco(
            carteira=u'9',
            agencia=u'02752',
            conta=u'14978-0',
            data_vencimento=datetime.date(2011, 3, 9),
            valor_documento=2952.95,
            nosso_numero=u'75896452',
            numero_documento=u'75896452')
        self.assertEquals(
            x.barcode, '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', 'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '100')
예제 #12
0
class TestBancoBradesco(DomainTest):
    def setUp(self):
        payment = self.create_payment(value=Decimal('8280'),
                                      date=datetime.date(2011, 2, 5))
        bank = self.create_bank_account(bank_branch=u'278-0',
                                        bank_account=u'039232-4',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'2125525')
        payment.method.destination_account.bank = bank
        self.dados = BankBradesco(payment)

        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(bank_branch=u'1172',
                                        bank_account=u'403005',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'06')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        self.dados2 = BankBradesco(payment)

    def test_linha_digitavel(self):
        self.assertEqual(self.dados.linha_digitavel,
                         '23790.27804 60000.212559 25003.923205 4 48690000828000'
                         )

        self.assertEqual(self.dados2.linha_digitavel,
                         '23791.17209 60007.589645 52040.300502 1 49010000295295'
                         )

    def test_codigo_de_barras(self):
        self.assertEqual(self.dados.barcode,
                         '23794486900008280000278060000212552500392320'
                         )
        self.assertEqual(self.dados2.barcode,
                         '23791490100002952951172060007589645204030050'
                         )

    def test_agencia(self):
        self.assertEqual(self.dados.agencia, '0278-0')

    def test_conta(self):
        self.assertEqual(self.dados.conta, '0039232-4')

    def test_validate_field(self):
        valid = ['0278-0',
                 '1172',
                 '14978-0',
                 '403005',
                 '0039232-4',
                 '02752']
        for v in valid:
            self.dados.validate_field(v)

    def test_dv_nosso_numero(self):
        self.dados.nosso_numero = '1236'
        self.assertEqual(self.dados.dv_nosso_numero, 'P')

        self.dados.nosso_numero = '1244'
        self.assertEqual(self.dados.dv_nosso_numero, 0)

    def test_carteira(self):
        payment = self.create_payment(value=Decimal('2952.95'),
                                      date=datetime.date(2011, 3, 9))
        bank = self.create_bank_account(bank_branch=u'02752',
                                        bank_account=u'14978-0',)
        bank.add_bill_option(u'especie_documento', u'DM')
        bank.add_bill_option(u'carteira', u'9')
        bank.add_bill_option(u'nosso_numero', u'75896452')
        account = self.create_account()
        account.bank = bank
        payment.method.destination_account = account
        x = BankBradesco(payment)
        self.assertEqual(
            x.barcode, '23793490100002952952752090007589645200149780')

        x.validate_option(u'carteira', '9')
        x.validate_option(u'carteira', '09')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', 'CNR')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '-1')
        self.assertRaises(BoletoException, x.validate_option, u'carteira', '100')