Exemplo n.º 1
0
    def test_calculate_account_banrisul_valid(self):
        bank = BANRISUL['correct_account']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            calculate_account = CalculateAccount(
                account=bank[i][0]).calculate_account_banrisul()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i][1])
        assert digits_calculated == accounts_digit
Exemplo n.º 2
0
    def test_calculate_account_bradesco_invalid(self):
        bank = BRADESCO['invalid_combinations']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=bank[i]['account']).calculate_account_bradesco()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated != accounts_digit
Exemplo n.º 3
0
    def test_calculate_account_nubank_valid(self):
        bank = NUBANK['valid_combinations']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=bank[i]['account']).calculate_account_nubank()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated == accounts_digit
Exemplo n.º 4
0
    def test_calculate_account_caixa_invalid(self):
        bank = CAIXA_ECONOMICA_FEDERAL['invalid_combinations']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=bank[i]['account']).calculate_account_caixa()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated != accounts_digit
Exemplo n.º 5
0
    def test_calculate_account_santander_invalid(self):
        bank = SANTANDER['invalid_combinations']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=bank[i]['account']).calculate_account_santander()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated != accounts_digit
Exemplo n.º 6
0
    def test_calculate_account_itau_invalid(self):
        bank = ITAU['invalid_combinations']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            account = bank[i]['branch'] + bank[i]['account']
            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=account).calculate_account_itau()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated != accounts_digit
Exemplo n.º 7
0
    def check_number_calculate_account(**kwargs):
        """
            Performs the validation and calculation of bank accounts
        """
        agency, account, digit_account, length_account, bank = kwargs.values()

        if len(account) < length_account:
            account = f'%0{length_account}d' % int(account)

        result_valid_account = CommonValidate.account_is_valid(account)

        if not result_valid_account:
            raise InvalidAccountNumber()

        result_valid_digit_account = CommonValidate.account_digit_is_valid(
            digit_account)

        if not result_valid_digit_account:
            raise InvalidDigitAccountNumber()

        switcher = {
            'bb': CalculateAccount(account=account).calculate_account_bb,
            'bradesco':
            CalculateAccount(account=account).calculate_account_bradesco,
            'itau': CalculateAccount(account=account).calculate_account_itau,
            'santander':
            CalculateAccount(account=account,
                             agency=agency).calculate_account_santander,
            'citibank':
            CalculateAccount(account=account).calculate_account_citibank,
            'banrisul':
            CalculateAccount(account=account).calculate_account_banrisul,
            'caixa': CalculateAccount(account=account,
                                      agency=agency).calculate_account_caixa,
            'nubank':
            CalculateAccount(account=account).calculate_account_nubank,
        }

        result_check_number_account = switcher.get(bank)()

        if not result_check_number_account:
            raise InvalidAccountNumber()

        return result_check_number_account
Exemplo n.º 8
0
    def test_calculate_account_bb_valid(self):
        bank = BANCO_DO_BRASIL['valid_combinations']
        digits_calculated = []
        accounts_digit = []

        for i in range(len(bank)):
            account = bank[i]['account']
            if len(account) < 8:
                account = f'%08d' % int(account)

            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=account).calculate_account_bb()

            digits_calculated.append(calculate_account)
            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated == accounts_digit
Exemplo n.º 9
0
    def test_calculate_account_bradesco_valid(self):
        bank = BRADESCO['valid_combinations']
        digits_calculated = []
        accounts_digit = []
        for i in range(len(bank)):
            account = bank[i]['account']
            if len(account) < 7:
                account = f'%07d' % int(account)

            calculate_account = CalculateAccount(
                agency=bank[i]['branch'],
                account=account).calculate_account_bradesco()

            digits_calculated.append(calculate_account)
            if bank[i]['account_digit'] == '0' or bank[i][
                    'account_digit'] == 'P':
                bank[i]['account_digit'] = calculate_account

            accounts_digit.append(bank[i]['account_digit'])

        assert digits_calculated == accounts_digit