Ejemplo n.º 1
0
def test_should_throw_policy_exception():
    with pytest.raises(PolicyException, match='Política negada: commitment'):
        fake_adapter = FakeExternalApiAdapter(900, Decimal(0.9))
        loan = Loan('name', 'cpf', datetime.date(2000, 7, 12), Decimal(2500),
                    6, Decimal(1000))
        loan.person_score = 900
        CommitmentPolicy(fake_adapter).apply(loan)
Ejemplo n.º 2
0
def test_should_pass_policy_with_other_terms():
    fake_adapter = FakeExternalApiAdapter(900, Decimal(0.66))
    loan = Loan('name', 'cpf', datetime.date(2000, 7, 12), Decimal(2500), 6,
                Decimal(1000))
    loan.person_score = 900
    CommitmentPolicy(fake_adapter).apply(loan)
    assert loan.terms == 9
Ejemplo n.º 3
0
 def apply(self, loan: Loan):
     person_score = self.external_api_port.get_person_score(loan.cpf)
     loan.person_score = person_score
     if person_score < 600:
         raise PolicyException('score')