def test_double_transactions(transaction, expected_return, starter_history):
    """
    Método que testa os casos em que é esperada que a exceção
    `DoubleTransactionsException` seja lançada.
    """
    validator_object = validator.Validator(starter_history=starter_history)

    assert validator_object.validateOne(transaction) == expected_return

    with pytest.raises(exceptions.DoubleTransactionsException):
        transaction_data = transaction['transaction']
        validator_object.verify_double_transactions(transaction_data)
def test_minimum_installments(transaction, expected_return):
    """
    Método que testa os casos em que é esperada que a exceção
    `MinimumInstallmentsException` seja lançada.
    """
    validator_object = validator.Validator()

    assert validator_object.validateOne(transaction) == expected_return

    with pytest.raises(exceptions.MinimumInstallmentsException):
        transaction_data = transaction['transaction']
        validator_object.verify_minimum_installments(transaction_data)
def test_compromised_income(transaction, expected_return):
    """
    Método que testa os casos em que é esperada que a exceção
    `CompromisedIncomeException` seja lançada.
    """
    validator_object = validator.Validator()

    assert validator_object.validateOne(transaction) == expected_return

    with pytest.raises(exceptions.CompromisedIncomeException):
        transaction_data = transaction['transaction']
        validator_object.verify_compromised_income(transaction_data)
def test_double_transactions(transaction, expected_return, starter_history):
    """
    Método que testa os casos em que é esperada que a exceção
    `DoubleTransactionsException` seja lançada.
    """
    validator_object = validator.Validator(starter_history=starter_history)
    raised = False

    try:
        transaction_data = transaction['transaction']
        validator_object.verify_double_transactions(transaction_data)

        returned = validator_object.validateOne(transaction)

    except exceptions.DoubleTransactionsException:
        raised = True

    assert returned == expected_return
    assert raised == False
def test_minimum_installments(transaction, expected_return):
    """
    Método que testa os casos em que é esperada que a exceção
    `MinimumInstallmentsException` seja lançada.
    """
    validator_object = validator.Validator()
    raised = False

    try:
        transaction_data = transaction['transaction']
        validator_object.verify_minimum_installments(transaction_data)

        returned = validator_object.validateOne(transaction)

    except exceptions.MinimumInstallmentsException:
        raised = True

    assert returned == expected_return
    assert raised == False
def test_compromised_income(transaction, expected_return):
    """
    Método que testa os casos em que é esperada que a exceção
    `CompromisedIncomeException` não seja lançada.
    """
    validator_object = validator.Validator()
    raised = False

    try:
        transaction_data = transaction['transaction']
        validator_object.verify_compromised_income(transaction_data)

        returned = validator_object.validateOne(transaction)

    except exceptions.CompromisedIncomeException:
        raised = True

    assert returned == expected_return
    assert raised == False