def setUp(self): self.a_client_decorator = ClientDecorator() self.a_client = Person() self.a_client_decorator.decorate(self.a_client) self.a_bank_account_decorator = BankAccountDecorator(self.a_client, '1234 5 - 6') #test doubles won't work given type checking rules, using classic self.a_machine = Machine()
def and_an_individual_customer_with_account_number_account_number_asks_for_a_personal_loan( step, account_number): world.a_machine = Machine() a_client = Person() a_client_decorator = ClientDecorator() a_client_decorator.decorate(a_client) world.account = BankAccountDecorator(a_client, account_number) world.account.average_credit = 2501 world.account.decorate(world.a_machine)
def it_check_association_with_loan_request(self): a_client_decorator = ClientDecorator() a_client = Person() a_client_decorator.decorate(a_client) #set the rule base RuleManager.rule_base = BankSystemRuleBase() # (Loan, 'I am not a loan request') | should | throw(AssociationError) a_credit_analyst_decorator = CreditAnalystDecorator('12345-6') an_account = BankAccountDecorator(a_client, '1234567-8') a_loan_request = LoanRequest(an_account, 7000, a_credit_analyst_decorator) (Loan, a_loan_request) | should_not | throw(AssociationError)
def it_check_associations_with_bank_account_and_credit_analyst(self): a_client = Person() a_client_decorator = ClientDecorator() a_client_decorator.decorate(a_client) an_account = BankAccountDecorator(a_client, '12345-6') #set the rule base RuleManager.rule_base = BankSystemRuleBase() # an_account = BankAccountDecorator(a_client, '12345-6') an_analyst = CreditAnalystDecorator('abcde-f') (LoanRequest, 'I am not an account', 123, an_analyst) | should | throw(AssociationError) (LoanRequest, an_account, 123, 'I am not an analyst') | should | throw(AssociationError) (LoanRequest, an_account, 123, an_analyst) | should_not | throw(AssociationError)
def it_discount_a_check(self): #Discounting a check, it should work! a_machine = Machine() a_client = Person() a_client_decorator = ClientDecorator() a_client_decorator.decorate(a_client) a_bank_account_decorator = BankAccountDecorator(a_client, "1234-5") a_bank_account_decorator.decorate(a_machine) a_bank_account_decorator.deposit(100) a_bank_account_decorator.average_credit | should | equal_to(100) a_check = Check(id_="123", account_number="1234-5", value=10) self.an_attendant_decorator.discount_check(a_check) a_bank_account_decorator.average_credit | should | equal_to(90) #It should fail! other_bank_account_decorator = BankAccountDecorator(a_client, "1235-5") other_bank_account_decorator.average_credit = 100 other_bank_account_decorator.decorate(a_machine) a_check = Check(id_="123", account_number="1235-5", value=110) (self.an_attendant_decorator.discount_check, a_check) | should | throw(InsuficientFunds) other_bank_account_decorator.average_credit | should | equal_to(100)
def setUp(self): self.an_client_decorator = ClientDecorator() self.an_client = Person()