Esempio n. 1
0
def test_service_with_mercosul_plate_should_have_the_same_values_as_standard_plate():
    service_mercosul = SPService(
        license_plate="ABC1C34", renavam="11111111111", debt_option="all"
    )
    service_standard = SPService(
        license_plate="ABC1234", renavam="11111111111", debt_option="all"
    )

    response_mercosul = service_mercosul.debt_search()
    response_standard = service_standard.debt_search()

    assert len(response_mercosul) == 4
    assert len(response_standard) == 4
    assert response_mercosul['Multas'] == response_standard['Multas']
    assert response_mercosul['IPVAs'] == response_standard['IPVAs']
    assert response_mercosul['DPVATs'] == response_standard['DPVATs']
    assert response_mercosul['Licenciamento'] == response_standard['Licenciamento']
Esempio n. 2
0
def test_service_search_dpvat_fail(mocker):
    service = SPService(license_plate="ABC1234",
                        renavam="11111111112",
                        debt_option="dpvat")
    mocker.patch.object(service, 'debt_search')
    service.debt_search.return_value = 'Veículo não encontrado'
    result = service.debt_search()
    expected = 'Veículo não encontrado'
    assert result == expected
Esempio n. 3
0
def test_debt_search(license_plate, renavam, debt_option, output_file):
    with open(output_file, 'r') as f:
        output_ = json.load(f)

    service = SPService(license_plate=license_plate,
                        renavam=renavam,
                        debt_option=debt_option)
    search_result = service.debt_search()
    assert search_result == output_
Esempio n. 4
0
def test_service_with_paramater_licensing_should_return_only_licensing_api_items():
    service = SPService(
        license_plate="ABC1C34", renavam="11111111111", debt_option="licensing"
    )
    response = service.debt_search()
    assert len(response) == 4
    assert response['Licenciamento']
    assert response['DPVATs'] == None
    assert response['IPVAs'] == None
    assert response['Multas'] == None
Esempio n. 5
0
def test_service_with_paramater_all_should_return_all_api_items_available():
    service = SPService(
        license_plate="ABC1234", renavam="11111111111", debt_option="all"
    )
    response = service.debt_search()
    assert len(response) == 4
    assert response['Multas'] is not None
    assert response['IPVAs'] is not None
    assert response['DPVATs'] is not None
    assert response['Licenciamento'] is not None
Esempio n. 6
0
def test_service_with_mercosul_plate_should_succeed():
    service = SPService(
        license_plate="ABC1C34", renavam="11111111111", debt_option="all"
    )
    response = service.debt_search()
    assert len(response) == 4
    assert response['Multas'] is not None
    assert response['IPVAs'] is not None
    assert response['DPVATs'] is not None
    assert response['Licenciamento'] is not None
Esempio n. 7
0
def test_ipva_parser_values_should_succeed():
    service = SPService(
        license_plate="ABC1C34", renavam="11111111111", debt_option="ipva"
    )
    result = service.debt_search()
    parser = SPParser(data=result)

    response = parser.process_ipva_debts()

    assert type(response[0].get('amount')) == float
    assert response[0].get('description')
    assert response[0].get('title')
    assert response[0].get('type')
    assert response[0].get('year')
    assert response[0].get('year') == result.get('IPVAs').get('IPVA')[0].get('Exercicio')
Esempio n. 8
0
def test_service_search_licensing_success(mocker):
    service = SPService(license_plate="ABC1234",
                        renavam="11111111111",
                        debt_option="licensing")
    mocker.patch.object(service, 'debt_search')
    service.debt_search.return_value = {
        'Multas': None,
        'Licenciamento': {
            'Exercicio': 2021,
            'Veiculo': {
                'Placa': 'ABC1234',
                'Renavam': '11111111111',
                'UF': 'SP',
                'Proprietario': 'JOHN',
                'CPFCNPJ': '000.000.000-00'
            },
            'Servico': 'Licenciamento',
            'TaxaLicenciamento': 9891
        },
        'IPVAs': None,
        'DPVATs': None
    }

    result = service.debt_search()
    expected = {
        'Multas': None,
        'Licenciamento': {
            'Exercicio': 2021,
            'Veiculo': {
                'Placa': 'ABC1234',
                'Renavam': '11111111111',
                'UF': 'SP',
                'Proprietario': 'JOHN',
                'CPFCNPJ': '000.000.000-00'
            },
            'Servico': 'Licenciamento',
            'TaxaLicenciamento': 9891
        },
        'IPVAs': None,
        'DPVATs': None
    }

    assert result == expected
Esempio n. 9
0
def test_main_flow(license_plate, renavam, debt_option, output_file):
    with open(output_file, 'r') as f:
        output_ = json.load(f)

    service = SPService(license_plate=license_plate,
                        renavam=renavam,
                        debt_option=debt_option)
    search_result = service.debt_search()
    parser = SPParser(search_result)
    if debt_option == "ticket":
        result = parser.collect_ticket_debts()
    elif debt_option == "ipva":
        result = parser.collect_ipva_debts()
    elif debt_option == "dpvat":
        result = parser.collect_insurance_debts()
    elif debt_option == "licensing":
        result = parser.collect_licensing_debts()
    elif debt_option == None:
        result = parser.collect_all_debts()
    assert result == output_
Esempio n. 10
0
        elif len(sys.argv) == 4:    
            debt_option = sys.argv[1]
            license_plate = sys.argv[2]
            renavam = sys.argv[3]
        assert len(sys.argv) == 4 or len(sys.argv) == 3
    except (AssertionError, IndexError):
        print("Argumentos inválidos")
        sys.exit(1)

    service = SPService(
        license_plate=normalize_license_plate(license_plate),
        renavam=renavam,
        debt_option=debt_option
    )
    try:
        search_result = service.debt_search()
    except Exception as exc:
        print(exc)
        sys.exit(1)

    parser = SPParser(search_result)

    if debt_option == "ticket":
        result = parser.collect_ticket_debts()
    elif debt_option == "ipva":
        result = parser.collect_ipva_debts()
    elif debt_option == "dpvat":
        result = parser.collect_insurance_debts()
    elif debt_option == "licensing":
        result = parser.collect_licensing_debts()
    elif debt_option == None:
Esempio n. 11
0
def test_service_search_ticket_succsess(mocker):
    service = SPService(license_plate="ABC1234",
                        renavam="11111111111",
                        debt_option="ticket")
    mocker.patch.object(service, 'debt_search')
    service.debt_search.return_value = {
        'Multas': {
            'Multa': [{
                'AIIP': '5E5E5E5E  ',
                'DescricaoEnquadramento':
                'Estacionar em Desacordo com a Sinalizacao.',
                'Guia': 472535212,
                'Valor': 20118
            }, {
                'AIIP': '6F6F6F6F  ',
                'DescricaoEnquadramento':
                'Trans. Veloc. Super. a Maxima Permitidaem Ate 20%.',
                'Valor': 13166
            }]
        },
        'Licenciamento': {
            'Multas': {
                'Multa': [{
                    'AIIP': '5E5E5E5E  ',
                    'DescricaoEnquadramento':
                    'Estacionar em Desacordo com a Sinalizacao.',
                    'Guia': 472535212,
                    'Valor': 20118
                }, {
                    'AIIP': '6F6F6F6F  ',
                    'DescricaoEnquadramento':
                    'Trans. Veloc. Super. a Maxima Permitidaem Ate 20%.',
                    'Valor': 13166
                }]
            },
            'Veiculo': {
                'Placa': 'ABC1234',
                'Renavam': '11111111111',
                'UF': 'SP',
                'Proprietario': 'JOHN',
                'CPFCNPJ': '000.000.000-00'
            },
            'Servico': 'Multas'
        },
        'IPVAs': None,
        'DPVATs': None
    }
    result = service.debt_search()
    expected = {
        'Multas': {
            'Multa': [{
                'AIIP': '5E5E5E5E  ',
                'DescricaoEnquadramento':
                'Estacionar em Desacordo com a Sinalizacao.',
                'Guia': 472535212,
                'Valor': 20118
            }, {
                'AIIP': '6F6F6F6F  ',
                'DescricaoEnquadramento':
                'Trans. Veloc. Super. a Maxima Permitidaem Ate 20%.',
                'Valor': 13166
            }]
        },
        'Licenciamento': {
            'Multas': {
                'Multa': [{
                    'AIIP': '5E5E5E5E  ',
                    'DescricaoEnquadramento':
                    'Estacionar em Desacordo com a Sinalizacao.',
                    'Guia': 472535212,
                    'Valor': 20118
                }, {
                    'AIIP': '6F6F6F6F  ',
                    'DescricaoEnquadramento':
                    'Trans. Veloc. Super. a Maxima Permitidaem Ate 20%.',
                    'Valor': 13166
                }]
            },
            'Veiculo': {
                'Placa': 'ABC1234',
                'Renavam': '11111111111',
                'UF': 'SP',
                'Proprietario': 'JOHN',
                'CPFCNPJ': '000.000.000-00'
            },
            'Servico': 'Multas'
        },
        'IPVAs': None,
        'DPVATs': None
    }

    assert result == expected
Esempio n. 12
0
def test_service_search_ipva_success(mocker):
    service = SPService(license_plate="ABC1234",
                        renavam="11111111111",
                        debt_option="ipva")
    mocker.patch.object(service, 'debt_search')
    service.debt_search.return_value = {
        'Multas': None,
        'Licenciamento': {
            'Veiculo': {
                'Placa': 'ABC1234',
                'Renavam': '11111111111',
                'UF': 'SP',
                'Proprietario': 'JOHN',
                'CPFCNPJ': '000.000.000-00'
            },
            'IPVAs': {
                'IPVA': [{
                    'Exercicio': 2021,
                    'Valor': 136569,
                    'Cota': 8
                }, {
                    'Exercicio': 2020,
                    'Valor': 101250,
                    'Cota': 2
                }]
            },
            'Servico': 'IPVA'
        },
        'IPVAs': {
            'IPVA': [{
                'Exercicio': 2021,
                'Valor': 136569,
                'Cota': 8
            }, {
                'Exercicio': 2020,
                'Valor': 101250,
                'Cota': 2
            }]
        },
        'DPVATs': None
    }
    result = service.debt_search()
    expected = {
        'Multas': None,
        'Licenciamento': {
            'Veiculo': {
                'Placa': 'ABC1234',
                'Renavam': '11111111111',
                'UF': 'SP',
                'Proprietario': 'JOHN',
                'CPFCNPJ': '000.000.000-00'
            },
            'IPVAs': {
                'IPVA': [{
                    'Exercicio': 2021,
                    'Valor': 136569,
                    'Cota': 8
                }, {
                    'Exercicio': 2020,
                    'Valor': 101250,
                    'Cota': 2
                }]
            },
            'Servico': 'IPVA'
        },
        'IPVAs': {
            'IPVA': [{
                'Exercicio': 2021,
                'Valor': 136569,
                'Cota': 8
            }, {
                'Exercicio': 2020,
                'Valor': 101250,
                'Cota': 2
            }]
        },
        'DPVATs': None
    }

    assert result == expected